Question: Can anyone help me edit this code to where it fits the requirements in the Computation section? import java.util.Random; import java.util.Scanner; public class Prog04_MakeTable {
Can anyone help me edit this code to where it fits the requirements in the Computation section?
import java.util.Random;
import java.util.Scanner;
public class Prog04_MakeTable {
public static void main(String[] args)
{
int lowerLimit;
int upperLimit;
int temp = 0;
Scanner scan = new Scanner(System.in);
char choice = getChoice();
Random random = new Random();
System.out.print("Enter The Smallest operand For the Table: ");
lowerLimit = Integer.parseInt(scan.nextLine());
System.out.print("Enter The Largest operand For the Table: ");
upperLimit = Integer.parseInt(scan.nextLine());
while(upperLimit
{
System.out.println("Error! Largest Operand must be greater then the Smallest operand.");
System.out.print("Enter The Largest operand For the Table: ");
upperLimit = Integer.parseInt(scan.nextLine());
}
System.out.println();
System.out.printf("%-3c", choice);
for(int i = lowerLimit; i
System.out.printf("%6d", i);
System.out.println();
for(int i = lowerLimit; i
{
System.out.printf("%-3d", i);
for(int j = lowerLimit; j
{
if(choice == '+')
temp = i+j;
else if(choice == '-')
temp = i-j;
else if(choice == '*')
temp = i*j;
else if(choice == '/')
temp = i/j;
else if(choice == '%')
temp = i%j;
else if(choice == 'R') // checking if R was input
{
int row = i;
if(row > j)
row = -1 * row;
temp = row + random.nextInt(j - row + 1);
}
System.out.printf("%6d", temp);
}
System.out.println();
}
}
public static char getChoice()
{
char ch = 'x';
Scanner scan = new Scanner(System.in);
while(!(ch == '+' || ch == '-' || ch == '*'
|| ch == '%' || ch == 'R') )
{
System.out.print("Enter The Table Operator (+, -, *, /, %, or R): ");
ch = scan.nextLine().toUpperCase().charAt(0);
if(!(ch == '+' || ch == '-' || ch == '*'
|| ch == '%' || ch == 'R') )
System.out.println("Error! Input must be (+, -, *, /, %, or R).");
}
return ch;
}
}
You will write a program that will provide a text-based menu interface for users to access the functionality that you have developed in programs 2- 4. Based on the menu option selected by the user, you will run one of your previously developed programs, until your user decides to quit the menu Input: You will prompt the user to select a program using the following menu: INTERESTING PROGRAMS MENU [A]CALCULATE EASTER DATE [B] CALCULATE COMMISSION PAY C GENERATE CALCULATION TABLE [X] QUIT ENTER MENU OPTION: The menu interface should only accept the values of A","B", "C", and "X" as valid input from the user. If a user enters an invalid value, the program should notify the user that the value entered is incorrect, and why, and prompt the user to reenter a corrected value. Computation: You will create separate methods for each of your previous programs. You will copy and paste the content of each of your main program methods into the new methods in this program: public static void Prog02_EasterCalc )
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
