Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; class Main { public static void main(String[] args) { // Scanner is used for getting input. // Don't worry about this now. Scanner

import java.util.Scanner;

class Main { public static void main(String[] args) { // Scanner is used for getting input. // Don't worry about this now. Scanner input = new Scanner(System.in);

// These ints will be used for addition, subtraction and multiplication. System.out.println("What numbers would you like to do math with?"); int x = input.nextInt(); int y = input.nextInt(); // Closing the scanner input.close();

//Do NOT Make any changes to the above code! You will learn more about Scanner later. For example when you run the code type 6 and 4 in the console. The console being where your code output will show. Enter the two numbers below where is asks what numbers you would like to do math with. (If you want different numbers than 6 and 4 type those IN THE CONSOLE!!!! Your code should compile no matter the numbers you enter into the console and give you what the mathamatical functions are below. Choose any two whole numbers besides 0)

// 1. Print the sum of x and y. // 2. Print the difference of x and y.

// 3. Print the product of x and y.

// 4. Print the quotient of x and y.

} }

Description:

This activity will show you how to do simple math operations to int values. The values of int x and int y will be asked for in the console when you run the application yourself. You will have to put in two numbers you want to use. However for the test you just have to provide the code for printing out the sum, difference, product and quotient for x and y. Please follow the steps below:

Steps:

  1. Print the sum of x and y. (line 18)
  2. Print the difference of x and y. (line 21)
  3. Print the product of x and y. (line 24)
  4. Print the quotient of x and y. (line 27)

Test:

Use the test provided. This test accounts for the print statements.

Sample:

Input:

102

Output:

What numbers would you like to do math with?128205

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To achieve the desired functionality you need to perform the specified mathematical operations on th... 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

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Programming questions