Home / Expert Answers / Computer Science / write-a-java-application-that-will-solve-the-following-problem-your-program-will-request-the-user-t-pa734

(Solved): Write a Java application that will solve the following problem. Your program will request the user t ...



Write a Java application that will solve the following problem. Your program will request the user to input two integers and store each integer in a separate variable. Your program will then compute the sum, difference, product, quotient, and remainder of the two integers and store each value in an appropriately named variable of the appropriate type. For this project you will assume that the second integer input will never equal zero. Finally, your program will output the values of the sum, difference, product, quotient, and remainder in appropriately user-friendly statements, for example The sum of 7 plus 8 is 15 The difference of 7 minus 8 is -1 and so on.

***I have created a successful code thus far but I am not sure how to tweak it to meet the criteria (ie. "The sum of 7 plus 8 is 15", etc.). I appreciate any assistance with this. Thank you!

Here is what I have:

public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

        int firstNumber;
        int secondNumber;
        int sum;
        int difference;
        int product;
        int quotient;
        int remainder;

        System.out.print("Please enter the first integer ");
        firstNumber = input.nextInt();

        System.out.print("Please enter the second integer ");
        secondNumber = input.nextInt();

        sum = firstNumber + secondNumber;
        difference = firstNumber - secondNumber;
        product = firstNumber * secondNumber;
        quotient = firstNumber / secondNumber;
        remainder = firstNumber % secondNumber;

        System.out.printf("The Sum of is %d\n", +sum);
        System.out.printf("The Difference is %d\n", +difference);
        System.out.printf("The Product is %d\n", +product);
        System.out.printf("The Quotient is %d\n", +quotient);
        System.out.printf("The Remainder is %d\n", +remainder);

    }

}



We have an Answer from Expert

View Expert Answer

Expert Answer


In this question the user is asked to perform certain operatio
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe