Question: Java: Here is my code. I'm getting an error when I try to run the program. It has to do with the formatted section of

Java: Here is my code. I'm getting an error when I try to run the program. It has to do with the formatted section of my code. If you could tell me what is wrong and what to fix that would be appreciated.

Code:

package smith6;

import java.util.Scanner;

public class MyMath { public static void totaldiff(double num1, double num2) { double sum; double difference;

sum = num1 + num2; if (num1 > num2) difference = num1 - num2; else difference = num2 - num1; System.out.println("The total of " + num1 + " and " + num2 + " is " + sum); System.out.println("The positive difference between " + num1 + " and " + num2 + " is " + difference); } public static double product (double num1, double num2) { double product; product = num1 * num2; return product;

}

public static double quotient (double num1, double num2) { if (num1 < num2) return num2 / num1; else return num1 / num2; } public static void main(String[] args) { double inputnum1; double inputnum2; Scanner input = new Scanner(System.in); System.out.println("Enter two double numbers: "); inputnum1 = input.nextDouble(); inputnum2 = input.nextDouble(); totaldiff(inputnum1, inputnum2); System.out.println(inputnum1 + " times " + inputnum2 + " = " + product(inputnum1, inputnum2)); System.out.printf("%.3f", inputnum2 + " divided by%.3f ", inputnum1 + " = " + "%.3f", quotient(inputnum1, inputnum2)); }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!