Question

Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and...

Hi.
Intro Java hw help needed;



Update an existing Java program that inputs two integers and outputs their sum, quotient and remainder by adding code to also output the difference and product.

Hi.Intro Java hw help needed;Update an existing Ja
Hi.Intro Java hw help needed;Update an existing Ja
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
import java.lang.*;
import java.io.*;


class Hwk3
{
public static void main (String[] args) throws java.lang.Exception
{
  int integer1,integer2,result,quotient,remainder;
  Scanner stdin=new Scanner(System.in);
  System.out.println("Calculator");
  System.out.println("Enter two Integers");
  integer1=stdin.nextInt();
  integer2=stdin.nextInt();
  System.out.println("Integer1= "+integer1 +"   Integer2= "+integer2);
  System.out.println("Enter Option\n 1. Addition\n 2.Subtraction\n 3. Multiplication\n 4. Division");
  int option=stdin.nextInt();
  switch(option)
  {
   case 1: result=integer1+integer2;
           System.out.println("Addition Of two integers= "+result);
           break;
   case 2: result=integer1-integer2;
           System.out.println("Subtraction Of two integers= "+result);
           break;
   case 3: result=integer1*integer2;
           System.out.println("Multiplication Of two integers="+result);
           break;
   case 4: quotient=integer1/integer2;
           remainder=integer1%integer2;
            System.out.println("Quotient Of two integers= "+quotient);
             System.out.println("Remainder Of two integers= "+remainder);
           break;
   default: System.out.println("Enter the correct choice");
            break;
  }
  
}
}

output

a) addition,if option =1

Success time: 0.05 memory: 711680 signal:0

Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
  1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Addition Of two integers=  113

b)subtraction ,if option =2
Success time: 0.07 memory: 711680 signal:0
Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
 1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Subtraction Of two integers=  43


c)multiplication,option=3
if option=3
Success time: 0.06 memory: 711680 signal:0
Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
 1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Multiplication Of two integers=2730

d)division,option=4

  • Success time: 0.06 memory: 711680 signal:0

    Calculator
    Enter two Integers
    Integer1=  78   Integer2=  35
    Enter Option
     1. Addition
      2.Subtraction
     3. Multiplication
     4. Division
    Quotient Of two integers=  2
    Remainder Of two integers=  8

e) if option is not between 1 and 4

  • Success time: 0.06 memory: 711680 signal:0

    Calculator
    Enter two Integers
    Integer1=  78   Integer2=  35
    Enter Option
     1. Addition
      2.Subtraction
     3. Multiplication
     4. Division
    Enter the correct choice


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program that asks the user to enter 2 integers, obtains them from the...

    Write a java program that asks the user to enter 2 integers, obtains them from the user, determines if they are even or odd numbers and prints their sum, product, difference, and quotient (Division).

  • 2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum...

    2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum of both of the integers and all the numbers in between Write a Marie program that determines the largest of a series of positive integers provided by a user. The user will enter a -1 when she is finished. Up to 10 numbers will be provided by the user. Write a Marie program that accepts two positive integers, multiples them by repeated addition, and...

  • Write a program which takes in two integers and produces their quotient. Here is a sample...

    Write a program which takes in two integers and produces their quotient. Here is a sample of their output: If you input 135 and 12, the output should read: 135 divided by 12 is 11 remainder 3. using java, netbeans

  • Develop a menu-driven program that inputs two numbers and, at the user's option, finds their sum,...

    Develop a menu-driven program that inputs two numbers and, at the user's option, finds their sum, difference, product, or quotient. Program Raptor plz

  • Intro to Java Programming Write a method named isDivisible that takes two integers, n and m,...

    Intro to Java Programming Write a method named isDivisible that takes two integers, n and m, and that returns true if n is divisible by m, and false otherwise. Include your isDivisible() function as a method in Functions. In the main static method, demonstrate isDivisible() works by testing that it returns both possibilities correctly for a few different pairs of numbers. Include comments before your test code describing what's going on. The definition of divisibility is "One whole number is...

  • Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initia...

    Hi, I need help with a fixed-point method program. It has to be done in C. The inputs are: Initial approximation ρo, tolerance ε, and the maximum number of iterations MAXIT. The outputs are: Approximate solution ρ or "solution not found". STEP 1 Do i=1 STEP 2 While i≤ MAXIT, execute steps 3-6 STEP 3 Do ρ=ϕ(p) (calculate pi) STEP 4 If |ρ-ρo|<ε then output(ρ) (operation sucessful) END STEP 5 Do i=i+1 STEP 6 Do po=p (update po) STEP 7...

  • Please help C++ language Instructions Write a program that prompts the user to enter 50 integers...

    Please help C++ language Instructions Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs.

  • Need Help a Intro to Java Programming assignment Design a Area class that has three overloaded...

    Need Help a Intro to Java Programming assignment Design a Area class that has three overloaded static methods areaComputing to calculate the areas of circles, rectangles, and cylinders. Assume that data for circles and cylinders are all doubles and data for rectangles are integers. Code a test program AreaApp by creating at least two objects for each geometric shapes with different hard coded data at your choice for testing.

  • help please! due tomorrow! Write code in Java Write a program that takes as input an...

    help please! due tomorrow! Write code in Java Write a program that takes as input an unordered list of integers, creates a Btree of minimum degree t 4 and then outputs the sorted list of integers. A simple inorder traversal of the B tree will output the list of the integers in a increasing order. You can choose your programming language and the platform you run on. The documentation is required for any programming assignment.

  • In this lab, you complete a partially written Java program that includes methods that require multiple...

    In this lab, you complete a partially written Java program that includes methods that require multiple parameters (arguments). The program prompts the user for two numeric values. Both values should be passed to methods named calculateSum(), calculateDifference(), and calculateProduct(). The methods compute the sum of the two values, the difference between the two values, and the product of the two values. Each method should perform the appropriate computation and display the results. The source code file provided for this lab...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT