CHALLENGE ACTIVITY 1.8.1: Compute an expression. Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5, finalResult is 3.
CHALLENGE ACTIVITY 1.8.1: Compute an expression. Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5, finalResult is 3.
Chapter9: Using Classes And Objects
Section: Chapter Questions
Problem 9E
Related questions
Question
CHALLENGE ACTIVITY
1.8.1: Compute an expression.
Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5, finalResult is 3.
![CTU Class Homepage.
zy Section 1.8 - CS 226T: Java Progra X
✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/8
= zyBooks My library > CS 226T: Java Programming home > 1.8: Arithmetic expressions (int)
422784.2543518.qx3zqy7
5
6
7
8
9
10
11
12
13
14
15
AHABAANN
16
17
18
19
20
21
22}
pu
}
LUL
Scanner scnr = new Scanner(System.in);
int num1;
int num2;
int finalResult;
num1 = 4;
num2 = 5;
finalResult
Coding Challenge Activity Notes X +
num1 scnr.nextInt();
num2 = scnr.nextInt();
Testing with 4,5
MATTHILD 8/
=
System.out.print("Final result: ");
System.out.println(finalResult);
X Testing with 4, 11
Output differs.
Run X Not all tests passed
(num1 + num2) / 3;
Your output
Your output Final result: 3
highlights below.
Final result: 3
Expected output Final result: 5
zyBooks catalog
1 test
passed
All tests
passed
? Help/FAQ
Stacey Queen
X
:
7:40 AM
8/10/2022](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F788fc729-a951-45c4-9909-47eea7bbf82f%2F65d0dbd6-4eb7-4800-be2f-365553c9e674%2F91dh2b_processed.png&w=3840&q=75)
Transcribed Image Text:CTU Class Homepage.
zy Section 1.8 - CS 226T: Java Progra X
✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/8
= zyBooks My library > CS 226T: Java Programming home > 1.8: Arithmetic expressions (int)
422784.2543518.qx3zqy7
5
6
7
8
9
10
11
12
13
14
15
AHABAANN
16
17
18
19
20
21
22}
pu
}
LUL
Scanner scnr = new Scanner(System.in);
int num1;
int num2;
int finalResult;
num1 = 4;
num2 = 5;
finalResult
Coding Challenge Activity Notes X +
num1 scnr.nextInt();
num2 = scnr.nextInt();
Testing with 4,5
MATTHILD 8/
=
System.out.print("Final result: ");
System.out.println(finalResult);
X Testing with 4, 11
Output differs.
Run X Not all tests passed
(num1 + num2) / 3;
Your output
Your output Final result: 3
highlights below.
Final result: 3
Expected output Final result: 5
zyBooks catalog
1 test
passed
All tests
passed
? Help/FAQ
Stacey Queen
X
:
7:40 AM
8/10/2022
![CTU Class Homepage.
SCTU Messenger
✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/8
= zyBooks My library > CS 226T: Java Programming home > 1.8: Arithmetic expressions (int)
CHALLENGE
ACTIVITY
422784.2543518.qx3zqy7
5
6
7
Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5,
finalResult is 3.
1 import java.util.Scanner;
2
3 public class ComputingFinalResult {
9
10
11
EZENSKI
12
13
14
15
16
1.8.1: Compute an expression.
17
18
zy Section 1.8 - CS 226T: Java Progra X
Run
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int num1;
int num2;
int finalResult;
num1 scnr.nextInt ();
num2 = scnr.nextInt ();
num1 = 4;
num2 = 5;
finalResult (num1 + num2) / 3;
X Not all tests passed
Testing with 4,5
Your output
X Testing with 4, 11
Coding Challenge Activity Notes x b Password Reset | bartleby
Final result: 3
zyBooks catalog
1 test
passed
All tests
passed
? Help/FAQ
Stacey Queen
X
:
8:21 AM
8/10/2022](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F788fc729-a951-45c4-9909-47eea7bbf82f%2F65d0dbd6-4eb7-4800-be2f-365553c9e674%2F8h6umcd_processed.png&w=3840&q=75)
Transcribed Image Text:CTU Class Homepage.
SCTU Messenger
✰ learn.zybooks.com/zybook/CS226-2204A-03-2204A/chapter/1/section/8
= zyBooks My library > CS 226T: Java Programming home > 1.8: Arithmetic expressions (int)
CHALLENGE
ACTIVITY
422784.2543518.qx3zqy7
5
6
7
Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5,
finalResult is 3.
1 import java.util.Scanner;
2
3 public class ComputingFinalResult {
9
10
11
EZENSKI
12
13
14
15
16
1.8.1: Compute an expression.
17
18
zy Section 1.8 - CS 226T: Java Progra X
Run
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int num1;
int num2;
int finalResult;
num1 scnr.nextInt ();
num2 = scnr.nextInt ();
num1 = 4;
num2 = 5;
finalResult (num1 + num2) / 3;
X Not all tests passed
Testing with 4,5
Your output
X Testing with 4, 11
Coding Challenge Activity Notes x b Password Reset | bartleby
Final result: 3
zyBooks catalog
1 test
passed
All tests
passed
? Help/FAQ
Stacey Queen
X
:
8:21 AM
8/10/2022
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,