7.1k views
0 votes
Write a program named IntegerExpressions that asks the user for three integers.

The program must then output results based on the following calculations:

firstResult = The sum of firstInt and secondInt divided by thirdInt

secondResult = The product of secondInt and thirdInt divided by the sum of secondInt and firstInt

thirdResult = The product of firstInt and thirdInt mod by the secondInt


Note:

firstInt, secondInt, and thirdInt represent the three integers entered by the user.

firstResult, secondResult, and thirdResult represent the results of the calculations.

n mod m means the remainder obtained when n is divided by m.


The prompt to the user to enter the integers must be:

Enter firstInt:
Enter secondInt:
Enter thirdInt:



The output must be in the format:

First Result = firstResult
Second Result = secondResult
Third Result = thirdResult



Please make sure to end each line of output with a newline.

Please note that your class should be named IntegerExpressions.

My code:

import java.util.Scanner;
public class IntegerExpressions {
public static void main(String[] args) {
Scanner = new Scanner(System.in);

int userInput = scnr.next();
int firstInt;
int secondInt;
int thirdInt;

firstInt = userInput;
secondInt = userInput;
thirdInt = userInput;

int firstResult = (firstInt + secondInt)/ thirdInt;
int secondResult; (secondInt * thirdInt)/(secondInt + firstInt);
int thirdResult; firstInt * thirdInt % secondInt;

System.out.println("First Result = " + firstResult);
System.out.println("Second Result = " + secondResult);
System.out.println("Third Result = " + thirdResult);

}

}

Error Messages:
IntegerExpressions.java:16: error: not a statement
int secondResult; (secondInt * thirdInt)/(secondInt + firstInt);
^
IntegerExpressions.java:17: error: not a statement
int thirdResult; firstInt * thirdInt%secondInt);
^
IntegerExpressions.java:17: error: ';' expected
int thirdResult; firstInt * thirdInt%secondInt);
^
3 errors


I have no clue where I'm going wrong please help.

User Dbaxime
by
5.9k points

1 Answer

2 votes

Answer:

its the first result and reread the second result

Step-by-step explanation:

User Eric Miller
by
5.1k points