Menu
support@authoritypapers.com
+1(805) 568 7317

java assignment this is a basic calculator i need a warning prompt when a usertries 5122124

Java Assignment This is a Basic Calculator. I need a warning prompt when a usertries to divide by 0. “Im sorry, you can’t divide by 0.” I also need to use the following for the Random Number Generatorinstead of what I have. double randomVal = Math.random();

              

double randomNumber = (randomVal * (upper – lower)) + lower; My code is below. import java.util.Scanner; public class BasicCalculator { public static void main(String[] args) { float a, b, res; char choice, ch; Scanner scan = new Scanner(System.in); do { System.out.print(“1. Addn”); System.out.print(“2. Subtract n”); System.out.print(“3. Multiply n”); System.out.print(“4. Divide n”); System.out.print(“5. Generate Random Number n”); System.out.print(“Enter Your Choice : “); choice = scan.next().charAt(0); switch(choice) { case ‘1’ : System.out.print(“Enter Two Numbers with a space inbetween: “); a = scan.nextFloat(); b = scan.nextFloat(); res = a + b; System.out.print(“Result = ” + res); break; case ‘2’ : System.out.print(“Enter Two Numbers with a space inbetween: “); a = scan.nextFloat(); b = scan.nextFloat(); res = a – b; System.out.print(“Result = ” + res); break; case ‘3’ : System.out.print(“Enter Two Numbers with a space inbetween: “); a = scan.nextFloat(); b = scan.nextFloat(); res = a * b; System.out.print(“Result = ” + res); break; case ‘4’ : System.out.print(“Enter Two Numbers with a space inbetween: “); a = scan.nextFloat(); b = scan.nextFloat(); res = a / b; System.out.print(“Result = ” + res); break; case ‘5’ : System.out.print(“Enter the low number of your rangefirst and then the high number: “); a = scan.nextFloat(); b = scan.nextFloat(); res = a + b /2 + 2; System.out.print(“Result = ” + res); break;    default : System.out.print(“That is not a valid choice. Pleasetry again!”); break; } System.out.print(“n—————————————n”); }while(choice != 5); } } . . .

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"GET15"

Order Now