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 2.3, Problem 19STE
Given the following fragment that purports to convert from degrees Celsius to degrees Fahrenheit, answer the following questions:
double c = 20;
double f;
f = (9/5) * c + 32.0;
a. What value is assigned to f?
b. Explain what is actually happening, and what the programmer likely wanted.
c. Rewrite the code as the programmer intended.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Given the following fragment that purports to convert from degrees Celsius to degrees Fahrenheit, answer the following questions:double c = 20;double f;f = (9/5) * c + 32.0;a. What value is assigned to f?b. Explain what is actually happening, and what the programmer likely wanted.c. Rewrite the code as the programmer intended.
Consider the following code fragment, where the variable letter contains an uppercase letter:
if 'A' <= letter <= 'U':...print("You entered a vowel")else:...print("The letter is not a vowel")
Based on the ordering of characters in the ASCII table, which of the following statements is not true about this code?
Select one:
a. Prints You entered a vowel for all vowels
b. Prints You entered a vowel for all vowels and all consonants.
c. Prints You entered a vowel for some consonants.
d. Prints The letter is not a vowel for some consonants.
you are required to write a universal calculator that HALFs that value of the different types of data. Especially, the calculator must take the following types of input.1. a decimal number2. a float point number3. a binary number which must be prefixed with "0b" (e.g. 0b111, 0b1010 are valid. 01b1010, ob101, 01010 are invalid)4. a hexadecimal number which must be prefixed with "0x" (e.g. 0x19, 0xAA are valid. 01x1A, ox1A, 01A are invalid)
Please note that:Your program must implement function overloading. You can consider the examples below for your implementation. You are provided with the initial code which can be found. The initial code has already checked different types of input for you.
Chapter 2 Solutions
Problem Solving with C++ (10th Edition)
Ch. 2.1 - Give the declaration for two variables called feet...Ch. 2.1 - Give the declaration for two variables called...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Give a C++ statement that will increase the value...Ch. 2.1 - Give a C++ statement that will change the value of...Ch. 2.1 - Prob. 6STECh. 2.1 - Prob. 7STECh. 2.2 - Give an output statement that will produce the...Ch. 2.2 - Give an input statement that will fill the...Ch. 2.2 - Prob. 10STE
Ch. 2.2 - Write a complete C++ program that writes the...Ch. 2.2 - Write a complete C++ program that reads in two...Ch. 2.2 - Prob. 13STECh. 2.2 - Write a short program that declares and...Ch. 2.3 - Convert each of the following mathematical...Ch. 2.3 - Prob. 16STECh. 2.3 - What is the output of the following program lines...Ch. 2.3 - Write a complete C++ program that reads two whole...Ch. 2.3 - Given the following fragment that purports to...Ch. 2.3 - What is the output of the following program lines...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Suppose savings and expenses are variables of type...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Write an if-else statement that outputs the word...Ch. 2.4 - Consider a quadratic expression, say x2 x 2...Ch. 2.4 - Consider the quadratic expression x2 4x + 3...Ch. 2.4 - What is the output of the following cout...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What output would be produced in the previous...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - What is the most important difference between a...Ch. 2.4 - What is the output produced by the following (when...Ch. 2.4 - Write a complete C++ program that outputs the...Ch. 2.5 - The following if-else statement will compile and...Ch. 2.5 - Prob. 36STECh. 2.5 - Write a complete C++ program that asks the user...Ch. 2 - A metric ton is 35,273.92 ounces. Write a program...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - Many treadmills output the speed of the treadmill...Ch. 2 - Write a program that plays the game of Mad Lib....Ch. 2 - The following is a short program that computes the...Ch. 2 - A government research lab has concluded that an...Ch. 2 - Workers at a particular company have won a 7.6%...Ch. 2 - Modify your program from Programming Project 2 so...Ch. 2 - Negotiating a consumer loan is not always...Ch. 2 - Write a program that determines whether a meeting...Ch. 2 - Prob. 6PPCh. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Write a program that reads in ten whole numbers...Ch. 2 - Modify your program from Programming Project 9 so...Ch. 2 - Sound travels through air as a result of...Ch. 2 - Prob. 12PPCh. 2 - The HarrisBenedict equation estimates the number...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - It is important to consider the effect of thermal...Ch. 2 - Prob. 16PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the difference between the names defined in an ML let construct from the variables declared in a C bloc...
Concepts of Programming Languages (11th Edition)
Define each of the following terms: determinant functional dependency transitive dependency recursive foreign k...
Modern Database Management
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Describe the steps that are generally taken when an input validation loop is used to validate data.
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
A method in a subclass that has the same signature as a method in the superclass is an example of __________. a...
Starting Out with Java: Early Objects (6th Edition)
What are some features of specific programming languages you know whose rationales are a mystery to you?
Concepts Of Programming Languages
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
- Choose the best data type for each of the following, so that no memory storage is wasted. Give an example of a typical value that would be held by the variable, and explain why you chose the type you did. the number of years of school you have completed your final grade in this class the population of China the number of passengers on an airline flight one players score in a Scrabble game the number of Electoral College votes received by a U.S. presidential candidate the number of days with below freezing temperatures in a winter in Miami, Florida one teams score in a Major League Baseball gamearrow_forwardWrite a C program that accepts an integer and determines whether the number is divisible 2, 3 or 5? The format of the output should be like this: Input: 10 Output: 10 is divisible by 2 10 is not divisible by 3 10 is divisible by 2 (Note: Kindly provide comments in your code that clearly explain what each main section of the code is accomplishing and how.)arrow_forwardYour task is to complete the code below in order to evaluate the results of four basic arithmetic operations. # input a float value for variable a here# input a float value for variable b here # output the result of addition here# output the result of subtraction here# output the result of multiplication here# output the result of division here print("\nThat's all, folks!") The results have to be printed to the console. You may not be able to protect the code from a user who wants to divide by zero. That's okay, don't worry about it for now. Test your code - does it produce the results you expect? We won't show you any test data - that would be too simple.arrow_forward
- Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 ''' Type your code here. '''arrow_forward7_. Write a program to request for three number, your program should determine: i. the largest of the number ii. the average of the numbers You NB: the numbers are of type int and Scanner must be used. b. The electoral commission of Ghana is trying to find out the eligibility of voters in the country, on a trial bases you were tasked to come out with a program that request for: i. A person's country of residence; ii. The person's age; iii. The person should be eligible to vote if he comes from Ghana and is at least 18 years of age. NB: country and age should be declared as string and float respectively, You can use either "Scanner of JOtionPane" to collect the variables bor 1 of 1 125 words DR English (United States).arrow_forwardYou must implement a C++ program that calculates the position and velocity of a body thrown with an initial velocity (v0) and with an angle to the horizontal (angle). The results should be displayed on the screen every some time (0.1 seconds) in a horizontal row. To validate your program, use the following example run where v0=10 and angle=53o as shown in the image: The data must be printed with two decimal places, find out how to do this in C++.Once all the calculations are printed, the program must ask if you want to repeat or if you want to exit the program. You implement the way to do it.As always the report should include (use the standard report): Cover page with title, course and section, names and student numbers of your team members in alphabetical order by last name.Introduction indicating in one paragraph what the program does and pseudocode/algorithm of the program. Detailed flowchart. Source code. Pictures of a running example. Next, the theory of ballistics problems:…arrow_forward
- Thank you so much for the prompt reply. However, this code is not working. I"m getting an error with the last part of the code : def main(): # get user input a, b, c = [int(x) for x in input().split()] # call function res = max_magnitude(a, b, c) print(res) Error states a b c is not definedarrow_forward2- Write a Python program that determines a student’s grade. The program will read three types of scores(quiz, midterm, final exam scores) and determine the grade based on the following rules : if the average score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if the average score>=50% and <70% =>grade=C -if the average score<50% =>grade=F Example Input : Quiz score: 80 Mid-term score: 68 Final score: 90 Output: Your grade is B.arrow_forwardby using c++ solve following questions. 1. Write a program that inputs age in years and displays age in days and months. 2. Write a program that inputs two times in hh:mm:ss format, adds both times and displays the total time.arrow_forward
- Write C program which should print your name and registration number on the screen then do the following:an industry has launched an online shopping ordering system which sells 5 different products. A list of productnumber, product name and their retail price is given below:Product No. Product Name Retail Price in Rs. Quantity Available101 Soap 60.00 10102 Liquid Hand Wash 200.00 20103 Liquid Dish Wash 150.00 30104 Table cleaner 350.00 40105 Hand Sanitizer 100.00 50 Your program must store this information in an array of struct product type. You must declare the struct product_type. (HINT: You can make any other structures or arrays of structures that you think might help you solve this problem.) Your program should…arrow_forwardI'm trying to find the best way to give "args" a input variable, it isn't working like how I want. These are the instructions my professor wants me to follow: write a program that takes two double command line arguments representing the sides of a rectangleThe program should then call a void function that reports the area of the rectangle accurate to three decimal places public static void main(String args) { Scanner scan = new Scanner(System.in); System.out.println("Enter length and width of rectangle " + args); args = scan.nextLine(); for (int i=0; i < args.length; i++) { System.out.println(args[i]); } Double area= Double.parseDouble (args[0]) * Double.parseDouble (args[1]); System.out.println(" Area of rectangle is :" + String.format("%.3f", area)); } }arrow_forwardIn each of the following code snippets, data is copied from x to y. How many bytes of data arecopied? The answer should be a C expression.Example: int x[10], y[10];...for (int i=0; i<10; i++)x[i] = y[i];Answer: 10*sizeof(int)Example: int *x, *y; ...; y = x;Answer: sizeof(int*) (e) int x=10, y=x;(f) int x[10]; int *y = x;(g) int x[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};void f(int y[5]) { ... }int main() { f(x); }(h) int x[10], y[10];...memcpy(y, x, 5*sizeof(int));arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
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