Question
New to Java; Been reading our textbook to get answers, but I just don't understand. Please help with the following! Create a class called MathTest
New to Java; Been reading our textbook to get answers, but I just don't understand. Please help with the following!
Create a class called MathTest
Outside of the class, import the Scanner library
Create a method called main
Inside main:
- Declare two integer variables and two double variables
- Instantiate a Scanner object
- Using print, display two lines that allows the user to enter in the two integer values on the same line as the prompt.
- Using print, display two lines that allows the user to enter in the two double values on the same line as the prompt.
- Using multiple printf statements, display the result of adding, subtracting, multiplying, dividing and moding the two integer values.
- Using multiple printf statements, display the result of adding, subtracting, multiplying, and dividing the two double values.
- Make sure that there is a title before each of the two outputs and there are blank lines between the input section and the two output sections.
- Comment your code.
Submit the .java file and a screen shot in Canvas
Screen Shot:
Input integer value 1: 5
Input integer value 2: 2
Input double value 1: 5.25
Input double value 2: 3.14
Integer output:
Adding 5 and 2 = 7
Subtracting 5 and 2 = 3
Multiplying 5 and 2 = 10
Dividing 5 and 2 = 2
Moding 5 and 2 = 1
Double output:
Adding 5.25 and 3.14 = 8.39
Subtracting 5.25 and 3.14 = 2.11
Multiplying 5.25 and 3.14 = 16.49
Dividing 5.25 and 3.14 = 1.67
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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