Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 11.1, Problem 7STE
The Pitfall section entitled “Leading Zeros in Number Constants” suggests that you write a short
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write C++ program from the pseodocode
. Design a program that computes pay for employees. Allow a user to continuously input employees' names until an appropriate sentinel value is entered. Also input each employee's hourly wage and hours worked. Compute each employee's gross pay (hours times rate), withholding tax percentage withholding tax amount, and net pay (gross pay minus withholding tax). Display all the results for each employee. After the last employee has been entered, display the sum of all the hours worked, the total gross payroll, the total withholding for all employees, and the total net payroll.
//Pseudocode
//start// Declarations// string empName// num salary// num hrsWorked// num x// num grossPay// num withTax// num netPay// num totalGrossPay=0// num totalHrsWorked=0// num totalWithTax=0// num totalNetPay=0// string QUIT = "zzzz"// num SIZE = 4// num WITH_RATES[SIZE]= 0.10, 0.13, 0.16, 0.20// num WITH_RANGES[SIZE]= 0, 300.01, 550.01, 800.01
// getReady()// while…
In c++ please.
Given the sample code above in generating a random number. Create a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows.
1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors.(Don’t display the computer’s choice yet.)
2. The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard.
(You can use a menu if you prefer.)3. The computer’s choice is displayed.
4. A winner is selected according to the following rules:
a. If one player chooses rock and the other player chooses scissors, then rock wins.(The rock smashes the scissors.)
b. If one player chooses scissors and the other player chooses paper, then scissor wins. (Scissors cuts paper.)
c. If one player chooses paper and the other…
In this lab, you will write a MIPS program to convert Fahrenheit temperature to Celsius. A basic conversion program was taught in the class. You should utilize that code from the lecture slides. Your program will take the Fahrenheit temperature as user input (single precision floating point). The temperature conversion code will be a leaf procedure that will be called from the main program after the user input. The procedure also will print the single precision floating value of the Celsius temperature. After the program returns to the main program, the user will be asked if they want another conversion. A character will be taken as input to indicate the user’s preference. If the input character is ‘y’, the program will continue from the beginning by taking another input and calling the conversion procedure. Any other input character will make the program exit.
You may need to learn a few syscall parameters that deal with character and single precision floating point numbers. You will…
Chapter 11 Solutions
Problem Solving with C++ (10th Edition)
Ch. 11.1 - Write a function definition for a function called...Ch. 11.1 - What is the difference between a friend function...Ch. 11.1 - Suppose you wish to add a friend function to the...Ch. 11.1 - Prob. 4STECh. 11.1 - Notice the member function output in the class...Ch. 11.1 - Notice the definition of the member function input...Ch. 11.1 - The Pitfall section entitled Leading Zeros in...Ch. 11.1 - Give the complete definition of the member...Ch. 11.1 - Why would it be incorrect to add the modifier...Ch. 11.1 - What are the differences and the similarities...
Ch. 11.1 - Given the following definitions: const int x = 17;...Ch. 11.2 - What is the difference between a (binary) operator...Ch. 11.2 - Prob. 13STECh. 11.2 - Suppose you wish to overload the operator = so...Ch. 11.2 - Prob. 15STECh. 11.2 - Give the definition for the constructor discussed...Ch. 11.2 - Here is a definition of a class called Pairs....Ch. 11.2 - Following is the definition for a class called...Ch. 11.3 - Give a type definition for a structure called...Ch. 11.3 - Write a program that reads in five amounts of...Ch. 11.3 - Change the class TemperatureList given in Display...Ch. 11.3 - Prob. 22STECh. 11.3 - If a class is named MyClass and it has a...Ch. 11.4 - Prob. 24STECh. 11.4 - The following is the first line of the copy...Ch. 11.4 - Answer these questions about destructors. a. What...Ch. 11.4 - a. Explain carefully why no overloaded assignment...Ch. 11 - Modify the definition of the class Money shown in...Ch. 11 - Self-Test Exercise 17 asked you to overload the...Ch. 11 - Self-Test Exercise 18 asked you to overload the...Ch. 11 - Prob. 1PPCh. 11 - Define a class for rational numbers. A rational...Ch. 11 - Define a class for complex numbers. A complex...Ch. 11 - Enhance the definition of the class StringVar...Ch. 11 - Define a class called List that can hold a list of...Ch. 11 - Define a class called StringSet that will be used...Ch. 11 - This programming project requires you to complete...Ch. 11 - Redo Programming Project 6 from Chapter 9 (or do...Ch. 11 - Solution to Programming Project 11.12 To combat...Ch. 11 - Repeat Programming Project 11 from Chapter 10 but...Ch. 11 - Do Programming Project 19 from Chapter 8 except...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Tuition Increase At one college, the tuition for a full-time student is 8,000 per semester. It has been announc...
Starting Out with Python (4th Edition)
What is an object? What is a control?
Starting Out With Visual Basic (8th Edition)
Write a complete Java program that reads a line of keyboard input containing two values of type int separated b...
Java: An Introduction to Problem Solving and Programming (8th Edition)
What is the disadvantage of having too many features in a language?
Concepts Of Programming Languages
In Exercises 55 through 60, find the value of the given function where a and b are numeric variables of type Do...
Introduction To Programming Using Visual Basic (11th Edition)
Write Python statements that print the following: a. The words Computer Science Rocks, followed by an exclamati...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
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.Similar questions
- In this chapter, you learned that although a double and a decimal both hold floating-point numbers, a double can hold a larger value. Write a C# program named DoubleDecimalTest that declares and displays two variables-a double and a decimal. Experiment by assigning the same constant value to each variable so that the assignment to the double is legal but the assignment to the decimal is not. In other words, when you leave the decimal assignment statement in the program, an error message should be generated that indicates the value is outside the range of the type decimal, but when you comment out the decimal assignment and its output statement, the program should compile correctly.arrow_forwardHello, I was wondering if I could get help with this. The language I am using is Pythonarrow_forwardIn this lab, you will write a MIPS program to convert Fahrenheit temperature to Celsius. A basic conversion program was taught in the class. You should utilize that code from lecture slides. Your program will take the Fahrenheit temperature as a user input (single precision floating point). The temperature conversion code will be a leaf procedure that will be called from the main program after the user input. The procedure also will print the single precision floating value of the Celsius temperature. After the program returns to the main program, the user will be asked if they want another conversion. A character will be taken as input to indicate the user’s preference. If the input character is ‘y’, the program will continue from the beginning by taking another input and calling the conversion procedure. Any other input character will make the program exit. You may need to learn a few syscall parameters that deal with character and single precision floating point numbers. You will…arrow_forward
- The Café Noir Coffee Shop wants some market research on its customers. When a customer places an order, a clerk asks for the customer’s zip code and age. The clerk enters that data as well as the number of items the customer orders. The program operates continuously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more than 5 digits) or an invalid age (defined as less than 10 or more than 110), the program reprompts the clerk continuously. When the clerk enters fewer than 1 or more than 12 items, the program reprompts the clerk two more times. If the clerk enters a high value on the third attempt, the program accepts the high value, but if the clerk enters a negative value onthe third attempt, an error message is displayed and the order is not counted. At the end of the program, display a count of the number of items ordered by customers from the same zip code as the coffee shop (54984), and a count from other zip codes. Also…arrow_forwardProblem Description Did you know that in lotteries, a 3-digit number with the same numbers in all digits like 777 will hit the jackpot in a casino? In the same manner, let's make a program that will test if a certain 3-digit number hits a jackpot or not by identifying if all the digits of a given number is the same as the second inputted number. If it is, print "Jackpot!"; else, print "Nah". Input A line containing two integers separated by a space. 777·7 Output A line containing a string. Jackpot! -USED JAVA PROGRAMMING LANGUAGEarrow_forwardPlease help I don't know how to write the code Note: You've already written psuedocode of this problem in Homework 1: Question 1. Now, you just need to convert your algorithm to C++ code to solve this question. While shopping over the weekend for almond milk, you discover that all the almond milk cartons have square bases and varying heights. Write a program which takes user inputs for the side length of the square base of the carton in inches and the height of the carton in inches and outputs how many ounces a carton holds. You can use the following formula to convert cubic inches to ounces: ounces = 0.55 * cubic inches Hint: you should calculate cubic inches from the cartons dimensions before calculating ounces. The output should be the volume of the carton in ounces formatted with one-digit precision as shown below. You can use the setprecision() function with the fixed manipulator from the library to do so. --- Sample run ---: What is the side length of the base of the carton in…arrow_forward
- I used Visual Studio C++ and I can only use else or switch cases. C language is not allowed alsoarrow_forwardPython question Please explain this for me Thanks for your helparrow_forwardc++ You are working for a software firm that developped a word processor. A common error users often make is that they forget the caps locks on and print text like this: ”tHIS IS A SAMPLE of an error”, this usually happens at the beginning of a new sentence(i.e. right afer a dot or in a new line). Write a program to detect this error and fix it. The input will be a long string on keyboard.arrow_forward
- C++ One way to create a pseudo-random three digit number (and we are including one- and two-digit numbers as well) is rand()%1000. That gives numbers from 000 to 999, which is just what we want. Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is too high then the program should display "Too high, try again." If the user's guess is lower than the random number the program should say "Too low, try again." The program should use a loop that repeats until the user correctly guesses the random number. The program should keep track of the number of guesses the user makes. When the user correctly guesses the random number, the program should display the number of guesses. As specified, have the program tell the player how many guesses were used. A good player should always be able to find a three-digit number in ten or fewer guesses. The programs needs to include a menu that allows the user to select easy (3 digit number),…arrow_forwardPython programming only FIX THE ERRORS IN THE CODE EXERCISE Here is a program on calculating grades. Please correct the errors in the program.# Calculating Grades (ok, let me think about this one)# Write a program that will average 3 numeric exam grades, return an average test score, a corresponding letter grade, and a message stating whether the student is passing. # Average Grade# 90+ A# 80-89 B# 70-79 C# 60-69 D# 0-59 F# Exams: 89, 90, 90# Average: 90# Grade: A# Student is passing.# Exams: 50, 51, 0# Average: 33# Grade: F# Student is failing.exam_one = int(input("Input exam grade one: "))exam_two = input("Input exam grade two: "))exam_3 = str(input("Input exam grade three: "))grades = [exam_one exam_two exam_three]sum = 0for grade in grade: sum = sum + gradeavg = sum / len(grdes)if avg >= 90: letter_grade = "A"elif avg >= 80 and avg < 90 letter_grade = "B"elif avg > 69 and avg < 80: letter_grade = "C'elif avg <= 69 and avg >= 65: letter_grade = "D"elif:…arrow_forwardC++ In this task, you are required to write a code that converts an Octal number into its equivalent Decimal value or vice versa. The user first selects the conversion choice by inserting 1 or 2. Choice 1 is followed by inserting an Octal integer and getting its Decimal equivalent value as an output. Choice 2 requires inserting a Decimal integer and prints out its Octal equivalent. The Octal numeral system, is the base-8 number system, and uses the digits 0 to 7, that is to say 10 octal represents 8 Decimal and 100 octal represents 64 Decimal. Convertion from an Octal integer into Decimal In the Decimal system, each number is the digit multiplied by 10 to the power of its location (starting from 0). For example: 74 decimal = 7 x 10^1 + 4 x 10^0 1252 decimal = 1 x 10^3 + 2 x 10^2 + 5 x 10^1 + 2 x 10^0 each number is the digit multiplied by 8 to the power of its location (starting from 0). For example: 112 octal = 1 x 8^2 + 1 x 8^1 + 2 x 8^0 Converting an Octal integer into…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY