Question
In which format and how to save this file so that it would run ? import java.util.Scanner; public class Calculator { static Scanner scan =
In which format and how to save this file so that it would run ?
import java.util.Scanner; public class Calculator { static Scanner scan = new Scanner(System.in); public static int Modulus() { System.out.println("Enter Dividend: "); int Dividend=Integer.parseInt(scan.nextLine()); System.out.println("Enter Divisor: "); int Divisor=Integer.parseInt(scan.nextLine()); int Mod=Dividend % Divisor; return Mod; } public static int Division () { System.out.println("Enter Dividend: "); int Dividend=Integer.parseInt(scan.nextLine()); System.out.println("Enter Divisor: "); int Divisor=Integer.parseInt(scan.nextLine()); int Quotient=Dividend/Divisor; return Quotient; } public static double Exponential(int Base,int Expo) { double Result = Math.pow(Base,Expo); return Result; } public static void main(String[] args) { System.out.println("Enter your name: "); String Name=scan.nextLine(); while(true) { System.out.println("*** "+Name+"'s Arithmetic Calculator ***"); System.out.println("A. Perform Modulus Operation"); System.out.println("B. Perform Division Operation"); System.out.println("C. Perform Exponential Operation"); System.out.println("D. Quit program"); System.out.println(" Enter Your Choice Out of A,B,C or D"); String Choice=scan.nextLine(); if(Choice.equals("A")) { System.out.println(" Remainder is : "+Modulus()); } else if(Choice.equals("B")) { System.out.println(" Quotient is: "+Division()); } else if(Choice.equals("C")) { System.out.println("Enter Base: "); int Base=Integer.parseInt(scan.nextLine()); System.out.println("Enter Exponent: "); int Expo=Integer.parseInt(scan.nextLine()); System.out.println(" "+Base+"^"+Expo+":"+Exponential(Base,Expo)); } else if(Choice.equals("D")) { System.out.println(" Thank you for using my program "); System.exit(0); } else { System.out.println(" Sorry !!! Wrong Input. It must be A,B,C or D"); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To save the provided Java code so that it runs correctly follow these steps 1 Save the File Copy the ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started