Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming: Task Description: You are being tasked with a simple calculator program. All functionalities should be written in separate methods. The calculator should be

Java Programming: Task Description: You are being tasked with a simple calculator program. All
functionalities should be written in separate methods. The calculator should be able to
do the following:
Add
Subtract
Multiply
Divide
Square
Modulo
The calculator should do all of the above functions and print the results. For taking input
you can use the following:
public static int[] consoleInput(){
Scanner in = new Scanner(
System.in);
boolean continueloop = true;
int [] numberArr = new int[2];
while(continueloop == true){
System.out.printin("Enter Two Integer Numbers seperated by a space");
String numbers = in.nextLine ();
try .
numberArr[0]= Integer. parseInt(numbers.split ("")[0]);
numberArr[1]= Integer. parseInt(numbers.split ("")[1]);
return numberArr;
}catch(Exception e){
System.out.println("Try Again, impropper input");
}
}
in. close();
return numberArr;
}
To access, the values from the method:
Sample output:
Enter Two Integer Numbers seperated by a space
154
Addition: 19
Subtractions: 11
Multiplication: 60
Division: 3.0
Square of First: 225
Square of Second: 16
Modulus: 3
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions