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
Write a method call DisplaySineTable(), that prompts the user for a starting value and an step size. The method will calculate and display a table (10 rows) of sine values based on the user input. Use the built-in method Math.Sin() to obtain the sine of an angle. e.g. if the starting value is 0.5 and the step size is 0.03 the method will display the following table:
0.50 0.4794
0.53 0.5055
0.56 0.5311
0.77 0.6961
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps with 2 images
Knowledge Booster
Similar questions
- Java int[] numbers = {345, 632, 675, 157, 834, 294, 832};1. Write a method to find its highest value. 2. Write a method to find its lowest value. 3. Write a method to find its total value.arrow_forwardImage 1 is my code, and image 2 is how to calculate the score. i need to write 2 methods (Inalready wrote the method 3) Method 3: A method to collect the required patient information (age, zip code, insurance information, pain level, and temperature) and compute the priority score takes one Scanner parameter returns the computed score Method 4: A method to calculate the priority score of the patient (this method should be called in the method 3) takes five parameters, once for each patient feature returns the computed scorearrow_forwardin this code, the integer on each line shows the line number that is not part of code: what is the signature of the method sum: ____ 1 public static int sum(int x, int y){ 2 int z = x +y; 3 return z; 4 } 5 public static void main(String[] args){ 6 … 7 sum(a+2, b); 8 … 9 }arrow_forward
- In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste it in this document, along with the list of the problems you fixed.This example allows the user to display the string for the day of the week. For example, if the user passed the integer 1, the method will return the string Sunday. If the user passed the integer 2, the method will return Monday. This code has both syntax errors and logic errors. Hint: There are two logic errors to find and fix (in addition to the syntax errors).Inport daysAndDates.DaysOfWeek;public class TestDaysOfWeek {public static void main(String[] args) {System.out.println("Days Of week: ");for (int i = 0;i < 8;i++) {System.out.println("Number: " + i + "\tDay Of Week: " + DaysOfWeek.DayOfWeekStr(i) )}}}package daysAndDatespublic class DaysOfWeek {public static String DayOfWeekStr(int NumberOfDay) {String dayStr = ""switch (NumberOfDay) {case 1:dayStr =…arrow_forwardWrite the following two methods: computeDiameter: This method accepts the radius (r) of a circle, and returns its diameter (2*r; radius = 7.5). Declare all variables used here & initialize radius: Show method call: Write method code here: displayData: This method accepts two arguments: radius & diameter. The output should have appropriate messages on the screen. Show method call: Write method code here:arrow_forwardJava language Write a method to find the number of hours, minutes, and seconds and then display it as shown below. The method receives the total number of seconds as parameters. Output is Hour[totalSeconds=3750, nb_Hours=1, nb_Minutes=2, nb_Seconds=30]arrow_forward
- Write a program called LoopMethod (main method) that contains a method called printNums (method name) that prints the numbers from a specified start to end value. a) The main method will do the following: • asks the user for start and end number (int type). • calls the printNums methodb) The printNums method will do the following: • receives start and end number (parameters)• prints from the start to the end number using a loop Sample Run: Input start number: 3Input end number: 93 4 5 6 7 8 9Input start number: 9Input end number: 219 10 11 12 13 14 15 16 17 18 19 20 21arrow_forwardQ3. Create two methods: one that will reverse the order of the digits in an integer and a second determines if a number is a palindrome (i.e. reads the same front to back) using the following method headers. // Method 1: Takes in an integer and reverses it, e.g., reverse(456) returns 654 public static int reverse(int number) // Method 2: Takes in an integer and returns true if it is a palindrome. Use the reverse method you just wrote to implement this method. public static boolean isPalindrome(int number) Create a test program that asks the user to input an integer and provides feedback on whether the integer is a palindrome or not. Hint: To find the reverse number, use one of the following approaches: • Modify your numerical inputs to a string, then use a for loop to reverse the characters with string concatenation and the charAt() method. Retrieve individual digits and combine them in reverse order using the / and % operators, using ten as a divisor. Combine the digits with either…arrow_forwardChapter 5. PC #13. isPrime Method A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program. The program should ask the user to enter a number for primality test or a negative number to exit. Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. Test Case 1 Please enter a number to check for primality or -1 to exit:\n2ENTER2 is a prime number.\nPlease enter a number to check for primality or -1 to exit:\n3ENTER3 is a prime number.\nPlease enter a…arrow_forward
- Use the left to right addition method as outlined in the module to add the numbers. For the middle row of answers, if the number above needs an underline, type in an underline (_). Otherwise leave it blank. Show all work using the correct method on your handwritten work/answer sheet. 9818 + 3871arrow_forwardWe will rewrite the Sales Bar Chart question to use method for printing out the bar chart. The part where the asterisks are printed out should be done with a method. Use this method for each bar. The original question statement is here: Write a program that asks the user to enter today’s sales for five stores. The program should display a bar chart comparing each store’s sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Here is an example of the program’s output: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Enter today's sales for store 3: 1800 [Enter] Enter today's sales for store 4: 800 [Enter] Enter today's sales for store 5: 1900 [Enter] SALES BAR CHART Store 1: ********** Store 2: ************ Store 3: ****************** Store 4: ******** Store 5: *******************arrow_forwardThe method convertVolume() has an integer parameter. Define a second convertVolume() method that has two integer parameters. The first parameter is the number of gallons and the second parameter is the number of pints. The method should return the total number of pints. Ex: If the input is 9 2, then the output is: 9 gallons yields 72 pints. 9 gallons and 2 pints yields 74 pints. Note: The total number of pints can be found using (gallons * 8) + pints. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import java.util.Scanner; public class VolumeMethods { publicstaticintconvertVolume(intgallons) { returngallons*8; } /* Your code goes here */ publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); intgallonsUsed; intpintsUsed; inttotalPints1; inttotalPints2; gallonsUsed=scnr.nextInt(); pintsUsed=scnr.nextInt(); totalPints1=convertVolume(gallonsUsed);arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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