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 theCan 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 ) ) public static void Prog03_PayCalc() public static void Prog04_MakeTable )) Note that these methods do not need any parameters and they do not return a value. You will modify the new Prog02 EasterCalc, Prog03 PayCalc, and Prog04 MakeTable methods by creating additional methods to handle all of your input validation. In other words, these new methods will call other methods that perform the input validation for them. You should parameterize your validation methods, where possible, to minimize the number that you need to create. You will also create a method to handle input validation for the main method in this program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!