Practice Problem 8.7 (solution page 798)
Write a
linux>./snooze 5
CTRC+C
Slept for 3 of 5 secs.
linux
User hits Ctrl+C after 3seconds
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Concepts Of Programming Languages
Absolute Java (6th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Concepts of Programming Languages (11th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- Problem 2 (5 pts) Write a Python program that plays the game Ro-Sham-Bo (a.k.a., Rock, Paper, Scissors) for a player and a computer opponent. The player selects one of the options listed in a console prompt, then the computer randomly selects an option as well. The winner of the game is determined as follows: Rock beats Scissors - Scissors beats Paper - Paper beats Rock The same selection results in a tie. Your program must do the following: Prompt the player to enter a selection in the console. Provide instructions to user on what is a valid input. For example, you can have the integers 1, 2, and 3 represent the selection, or use the words rock, paper, scissors, etc. Check that the user entered valid input. If the entry is invalid, the program needs to inform the user of the invalid input and can end, or re-prompt the user for their entry. Generate a random selection for the computer's choice. You can use a random integer and follow the same rules as was stated to the user. - Display…arrow_forwardC++arrow_forwardC++ Programming. #19 onlyarrow_forward
- Problem: 9.19 LAB: Convert to binary - methodsWrite a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0Output x % 2 (remainder is either 0 or 1)x = x / 2Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string. Ex: If the input is: 6the output is: 110Your program must define and call the following two methods. The method integerToReverseBinary() should return a string of 1's and 0's representing the integer in binary (in reverse). The method reverseString() should return a string representing the input string in reverse. public static String integerToReverseBinary(int integerValue)public static String reverseString(String inputString) Java code:import java.util.Scanner; public class LabProgram {/* Define your method here */ public static String integerToReverseBinary(int…arrow_forwardneed help with this in c++arrow_forwardProblem:9.17 LAB: Count characters - methodsWrite a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. Ex: If the input is: n Mondaythe output is: 1Ex: If the input is: z Today is Mondaythe output is: 0Ex: If the input is: n It's a sunny daythe output is: 2Case matters. n is different than N. Ex: If the input is: n Nobodythe output is: 0Your program must define and call the following method that returns the number of times the input character appears in the input string.public static int countCharacters(char userChar, String userString) Java code:import java.util.Scanner; public class LabProgram {/* Define your method here */public static int countCharacters(char userChar, String userString) {int counter=0;for (int i=0; userString.length; i++) {if (userString.charAt(i)==userChar) {counter++; }}return counter;}}public static void main(String[] args) {/* Type your code here. */ Scanner scnr = new…arrow_forward
- C++arrow_forwardC ( answer fast please) Q1. Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and outcomes from command widow also add screen shots of any figures in your solution (3.0) Create a function called ‘My_Calc’ that satisfies the following criteria:. For x <4, f(x)= x^3; For x ≥4 and x<8 f(x)= x^2; For x ≥8, f(x)= 8.x; Plot your results for values of x from -5 to 25. Choose your spacing to create a smooth curve.arrow_forwardUSE C++ ONLY <IOSTREAM> THANK YOU 2. Write a lunch order program which allows to select lunch items accordingto the lunch menu provided below. (B) Burger with French Fries – 8.99 (C) Chicken and Rice – 9.50 (T) Tuna Sandwich – 10.49 (E) Exita) Write a function void takeOrder(int& burger, int& chicken, int& tuna);which will display the menu item, validate the entries and count how manyorders for each menu item: - Request one character for a lunch item. Menu options must be case insensitive (i.e. ‘E’ and ‘e’ must work). - Validate the input value. - Handle the menu (with a switch statement) to record how many orders for each item is taken. - The function must use pass by reference parameters to return how many orders for each menu item. - End the function only if Exit option is selected.b) Write a function payOrder(int burger, int chicken, int tuna) to print out how many orders are taken for each menu and calculate the total price.c) Call the functions in main() as…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education