Question

1. Write a Java application that uses recursion to compute the results of the following series: The program should compile and run without errors.
m(i) = 1 + 1/2 + 1/3 + 1/4 + 1/5 … + 1/i

2. Write a Java application that effectively uses Java collections to store pairs of unique colors and their unique hexadecimal values. (For example, Red -> FF0000). Store up to 20 of these pairs. Then write a GUI that displays the hexadecimal values using radio buttons to select a value. When selected the background of the GUI should change to that color. The program should compile and run without errors.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;


public class RecursiveSeries {

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int i;
System.out.print("Please enter in the value of i: ");
i = input.nextInt();
double total = recursive(i);

System.out.println("The result = " + total);

}

public static double recursive(int i)
{
double total = 0;
if(i > 0)
{
total = 1/(double)i;
total += recursive(i-1);
}
return total;
}
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Project For Consulting Company
Homework Solution
$50.00
Java
Programming
Computer Science
Consulting Company
Inventory
Interfaces
Products
Lookup
Classes
Libraries
Queries
Finance
Employees
Management
OOP
Function
Methods
Loops
Conditions
Cylinder Containers in Java
Homework Solution
$25.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Strings
Geometry
Mathematics
Cylinder
Radius
Finance
Costs
Containers
Companies
Functions
Get help from a qualified tutor
Live Chats