
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Change Summation Integers problem to Finding
the minimum problem. Move System.out.print statements, displaying results inside the methods,
making all your methods VOID.
![TASK 4. Intro to methods.
Review Methods, Implement the following code, make sure it runs without errors.
3 import java.util.Scanner;
4
5 public class ReportSum4 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
7
8
// Prompt the user to enter the first integer
System.out.println("Enter the value for 'a' and press Enter: ");
int a = sc.nextInt();
// Prompt the user to enter the second integer
System.out.println("Enter the value for 'b' and press Enter: ");
int b = sc.nextInt();
10
11
12
13
14
15
// Display the result
System.out.printf( "Provided Integers: %4d and %4d, the total is %5d\n", a, b, sum(a, b));
}
16
17
18
19
public static int sum(int num1, int num2){
return numl + num2;
}
200
21
22
23 }
Our client just contacted us and said that he's planning from time to time provide us three integers instead of
two. They still expect us to produce a report with totals (sums of their 2 or 3 integers)](https://content.bartleby.com/qna-images/question/545adfe4-d8f3-4ad6-9d6b-4da21555b9ec/b17b0f61-e25d-4e96-b1f4-ff4be935b03c/56ejjz_thumbnail.png)
Transcribed Image Text:TASK 4. Intro to methods.
Review Methods, Implement the following code, make sure it runs without errors.
3 import java.util.Scanner;
4
5 public class ReportSum4 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
7
8
// Prompt the user to enter the first integer
System.out.println("Enter the value for 'a' and press Enter: ");
int a = sc.nextInt();
// Prompt the user to enter the second integer
System.out.println("Enter the value for 'b' and press Enter: ");
int b = sc.nextInt();
10
11
12
13
14
15
// Display the result
System.out.printf( "Provided Integers: %4d and %4d, the total is %5d\n", a, b, sum(a, b));
}
16
17
18
19
public static int sum(int num1, int num2){
return numl + num2;
}
200
21
22
23 }
Our client just contacted us and said that he's planning from time to time provide us three integers instead of
two. They still expect us to produce a report with totals (sums of their 2 or 3 integers)
Expert Solution

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 nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- Complete the Team class implementation. For the instance method get_win_percentage(), the formula is:team_wins / (team_wins + team_losses)arrow_forwardWrite tests and implementarrow_forwardDo the trace in detail and submit The source Code As Well From the following recursive method Trace (in details) the calling of the above method with any input from your choice such that thereturned value will be 19. public static int think(int x) {if(x<10)if(x%2!=0)return x;elsereturn 0;elseif(x%2!=0)return x%10 + think(x/10);elsereturn think(x/10);}arrow_forward
- Write a method (with a parameter n), n: integer type that prints numbers from 1 to n. The print out should be 5 numbers per line. All the output numbers should be aligned well. Call the method with n=13 and n=10 in the main()arrow_forwardThis solution is unclear and does not answer my question. I am trying to add a main method to my code.arrow_forwardchange Summation Integers problem to Finding the minimumproblem. Make sure you properly wrote/updated all text messages, method names,and math calculations.Hint: You can use java.lang.Math.min() method.Example: System.out.printf("The min of the integers %4d and %4d and %4dis %7d\n", a, b, c, MinTest(a, b, c));arrow_forward
- TASK 8. Repeat TASKs 4-7. Change Summation Integers problem to Finding the minimumproblem. Make sure you properly wrote/updated all text messages, method names,and math calculations.Hint: You can use java.lang.Math.min() method.Example: System.out.printf("The min of the integers %4d and %4d and %4dis %7d\n", a, b, c, MinTest(a, b, c));Submit the source code files (.java files) and the console output screenshotsarrow_forwardWrite a method to convert an upper-case letter to a lower-case letter. (Hint: Check first to be sure that it is not lower case already.)arrow_forwardWrtie TWO methods pass number of birds and print number of birds in California (method1) and birds in Texas (Method 1) Print the total of birds. You can use void method.arrow_forward
- change Summation Integers problem to Finding the minimumproblem. Make sure you properly wrote/updated all text messages, method names,and math calculations.Hint: You can use java.lang.Math.min() method.Example: System.out.printf("The min of the integers %4d and %4d and %4dis %7d\n", a, b, c,d MinTest(a, b, c,d)); fix below code structurearrow_forwardSuppose that a friend tells you a phone number that you need to dial, as soon as you are done talking. You don’t have a pencil, so you remember it by grouping it into two sections, one with three digits, and one with four digits. The method you have used is calledarrow_forwardConsider the pseudo-code method below: PrintOnes (n) if n == 0 then print("1") else for i = 1 to 3 PrintOnes (n-1) Question 7 of 11 Click to see additional instructions How many times will "1" be printed when the method is called with a parameter of 3? A Questiarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY