Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Declare two integer variables and two double variables
  2. Instantiate a Scanner object
  3. Using print, display two lines that allows the user to enter in the two integer values on the same line as the prompt.
  4. Using print, display two lines that allows the user to enter in the two double values on the same line as the prompt.
  5. Using multiple printf statements, display the result of adding, subtracting, multiplying, dividing and moding the two integer values.
  6. Using multiple printf statements, display the result of adding, subtracting, multiplying, and dividing the two double values.
  7. 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.
  8. 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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago