
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
Please use JAVA in this form :
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Type your code here. */
}
}

Transcribed Image Text:Bowling involves 10 frames. Each frame starts with 10 pins. The bowler has two throws to knock all 10 pins down. The total score is the
sum of pins knocked down, with some special rules.
For the first 9 frames:
• If all 10 pins are knocked down on a frame's first throw (a "strike"), that frame's score is the previous frame plus 10 plus the next two
throws. (No second throw is taken).
• If all 10 pins are knocked down after a frame's second throw (a "spare"), that frame's score is the previous frame plus 10 plus the next
throw.
In the 10th frame, if the bowler's first throw is a strike, or the first two throws yields a spare, the bowler gets a third throw. The 10th frame's
score is the previous frame's score plus the pins knocked down in the 10th frame's two or three throws.
Given integers represents all throws for a game, output on one line each frame's score followed by a space (and end with a newline). Note
that the number of throws may be as few as 11 (strikes in first 9 frames, and no strike/spare in 10th frame), or as many as 21 (2 throws in
first 9 frames, then 3 in 10th).
For simplicity, the input will always have 21 integers. If the game ended with fewer than 21 throws, the remaining integers will be O's and
can be ignored.
Ex: A perfect game is one where every throw is a strike. The 21 input integers will be: 10 10 10 10 10 10 10 10 10 10 10 10
The output will be: 30 60 90 120 150 180 210 240 270 300.
00 0.
Hints:
• A first for loop should just read in the 21 scores in the first array.
• A second for loop should fill the second array's first 9 elements (first 9 frames).
• Additional code should compute the 10th frame, which is unique.
![Main.java
Load default template...
1 import java.util.Scanner;
2
3 public class Main {
public static void main(String[] args) {
4
5
Scanner scnr
new Scanner(System.in);
7 /* Type your code here. *
}
9 }
8](https://content.bartleby.com/qna-images/question/362eddf6-5d35-4699-896e-c3739e02ebfd/40458f85-94a3-490e-8a06-983eb20a6eb6/hwnygi_thumbnail.png)
Transcribed Image Text:Main.java
Load default template...
1 import java.util.Scanner;
2
3 public class Main {
public static void main(String[] args) {
4
5
Scanner scnr
new Scanner(System.in);
7 /* Type your code here. *
}
9 }
8
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 2 images

Knowledge Booster
Similar questions
- import java.util.Scanner; public class CircleAndSphereWhileLoop{ public static final double MAX_RADIUS = 500.0; public static void main(String[] args) { Scanner in = new Scanner(System.in); // Step 2: Read a double value as radius using prompt // "Enter the radius (between 0.0 and 500.0, exclusive): " // Step 3: While the input radius is not in the ragne (0.0, 500.0) // Display a message on one line (ssuming input value -1) // "The input number -1.00 is out of range." // Read a double value as radius using the same promt double circumference = 2 * Math.PI * radius; double area = Math.PI * radius * radius; double surfaceArea = 4 * Math.PI * Math.pow(radius, 2); double volume = (4 / 3.0) * Math.PI * Math.pow(radius, 3); // Step 4: Display the radius, circle circumference, circle area, // sphere surface area, and…arrow_forward1. What is the output of the following program? import java.util.Scanner; public class Factorial { public static void main(String args[]){ Scanner scanner = new Scanner(System.in); System.out.printIn("Enter the number:"); scanner.nextInt(); int factorial = fact(num); System.out.println("Factorial of int num = entered number is: "+factorial); } static int fact(int n) { int output; if(n==1){ return 1; } output = fact(n-1)* n; return output; } }arrow_forwardStringFun.java import java.util.Scanner; // Needed for the Scanner class 2 3 /** Add a class comment and @tags 4 5 */ 6 7 public class StringFun { /** * @param args not used 8 9 10 11 12 public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Please enter your first name: "); 13 14 15 16 17 18 System.out.print("Please enter your last name: "); 19 20 21 //Output the welcome message with name 22 23 24 //Output the length of the name 25 26 27 //Output the username 28 29 30 //Output the initials 31 32 33 //Find and output the first name with switched characters 34 //All Done! } } 35 36 37arrow_forward
- How do I code: public static void rotateElements(int[] arr, int rotationCount) public static void reverseArray(int[] arr) In Java?arrow_forwarddo this code using two classes Emi and main import java.util.Scanner; class Emi { public static void main(String []args) { Scanner a = new Scanner(System.in); double principal, rate, time, emi; System.out.print("Enter principal: "); principal = a.nextFloat(); System.out.print("Enter rate: "); rate = a.nextFloat(); System.out.print("Enter time in year: "); time = a.nextFloat(); rate=rate/(12*100); time=time*12; emi= (principal*rate*Math.pow(1+rate,time))/(Math.pow(1+rate,time)-1); System.out.print("Monthly EMI is= "+emi+"\n"); } }arrow_forwardWrite a function prototype and function header for a function called compute. The function should have 3 parameters: an int, a double and a long. The int parameter should have a default argument of 5, and the long parameter should have a default argument of 65536. The double parameter should have no default arguments. The parameters no necessarily in the order.arrow_forward
- How do I fix the result? import java.lang.*;import java.util.Scanner; // import the Scanner class public class Main { public static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { boolean doItAgain = false;do{doItAgain = false;calcType();System.out.println("Do you want to start over? (Y/N)");//Scanner keyboard = new Scanner(System.in);String decision = keyboard.next();if(decision.equals("Y")) {doItAgain = true;}}while(doItAgain);System.out.println("Goodbye");} public static void calcType() {String mode;System.out.println("Enter the calculator mode: Standard/Scientific?");//Scanner keyboard = new Scanner(System.in);mode = keyboard.next();if(mode.equals("Standard")) {standard();}else if (mode.equals("Scientific")) {scientific();}elseSystem.out.println("Unknown calculator type: " + mode);} public static void standard() {System.out.println("The calculator will operate in standard mode.");boolean doItAgain;do{doItAgain = false;System.out.println("Enter…arrow_forwardThe language is Java. The method to use is provided!arrow_forwardThe language is Java. The method to use is provided!arrow_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