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 8, Problem 18PP
Write a
For example, given the strings:
11:58:10 PM 12:02:15 AM |
The program should output that the time elapsed is 4 minutes and 5 seconds.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
computer programing
Write a program that reads from the user a character (*q' or 'c').
If the character is 'c', the program reads from the user the radius r of a circle and prints its area.
If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We
assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square
or rectangle.
Otherwise, it prints "Wrong character"
PS: Use the following formulas :
area of circle=3.14*r?
I
Write a program that reads student scores, gets the best score, andthen assigns grades based on the following scheme:Grade is A if score is ≥ best -5Grade is B if score is ≥best -10;Grade is C if score is ≥best -15;Grade is D if score is ≥best -20;Grade is F otherwise.The program prompts the user to enter the total number of students, and thenprompts the user to enter all of the scores, and concludes by displaying the grades.Here is a sample run:
Enter the number of students: 4 ↵EnterEnter 4 scores: 40 55 70 58 ↵EnterStudent 0 score is 40 and grade is FStudent 1 score is 55 and grade is CStudent 2 score is 70 and grade is AStudent 3 score is 58 and grade is C
Chapter 8 Solutions
Problem Solving with C++ (10th Edition)
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Look at the following pseudocode statement: Input temperature What happens when this statement executes?
Starting Out with Programming Logic and Design (4th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Describe what a compiler does with a programs source code.
Starting Out with C++ from Control Structures to Objects (8th Edition)
A superclass has the following method: public void setValue( int v) { value = v; } Write a statement that may a...
Starting Out with Java: Early Objects (6th Edition)
Our pipelined design is a bit unrealistic in that we have two write ports for the register file, but only the p...
Computer Systems: A Programmer's Perspective (3rd Edition)
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
- We want to create a program that reads a string and removes from it the characters between two marker characters. For example for the input text: (to buy) We need to buy (i) milk, (ii) eggs, (iii) flour, and (iv) sugar. And using "(" and ")" as the starting and ending markers, the program should output: We need to buy milk, eggs, flour, and sugar. Notice that the number of characters between the markers, and the number of markers present in the string may vary. We will assume that if a starting marker appears in the input text, its corresponding ending marker is also present in the string. Approach: The idea is to copy characters from the input text to an output string variable as long as we have not found the starting marker. From that point on, we ignore the characters in the input text until we find the ending marker. Once we find the ending marker, we resume copying characters to the output string variable, and the process repeats. Drag into the placeholders below the appropriate…arrow_forwardMany documents use a specific format for a person's name. Write a program that reads a person's name in the following format: firstName middleName lastName (in one line) and outputs the person's name in the following format: lastName, firstInitial.middleInitial. Ex: If the input is: Pat Silly Doe the output is: Doe, P.S. If the input has the following format: firstName lastName (in one line) the output is: lastName, firstInitial. Ex: If the input is: Julia Clark the output is: Clark, J.arrow_forwardAirline companies apply baggage restrictions for their passengers. An airline company has decided to apply a 10kg limitation for passengers' hand luggage and 20kg for their normal baggage. When passengers arrive, they enter their hand and normal luggage weight from the keyboard. If passengers exceed their normal baggage allowance of 10 dollars per gram, they pay 12 dollars per kg. Accordingly, write the program that calculates the baggage price of the airline they will go to according to the baggage values entered by the arriving passenger and keeps this from closing the program for each passenger. Note: If hand and normal baggage allowances are stretched below the maximum value, the payment amount will be considered not negative. An example printout is given on the right. Geri bildirim gönderarrow_forward
- Write a program to calculate the position of a projectile at a given time t. For an initial velocity vo and angle of departure ®g, the position is given by x and y coordinates as follows (note: the gravity constant g is 9.81 m/s²): X= V0 Cos (0)t y=vo sin (8,)t –; gt The program should initialize the variables for the initial velocity, time, and angle of departure. It should then call a function to find the x and y coordinates, and then another function to print the resultsarrow_forwarduse c languagre program.arrow_forwardWrite a C++ program that outputs the year's day number given a date in the format month-day-year. For example, if the date is January 1, 2006, the day number is 1; if the date is December 25, 2006, the day number is 359. A leap year should be checked by the program. A leap year is one that is divisible by four but not by one hundred. 1992 and 2008, for example, are divisible by 4, but not by 100. If a year is divisible by 100 and 400, it is considered a leap year. 1600 and 2000, for example, are divisible by 400. However, because 1800 is not divisible by 400, it is not a leap year.arrow_forward
- Write a program to calculate the grade point average (GPA) of a student by getting their grades for all their subjects. Grades and their grade points areGrade S 10 pointsGrade A 9 pointsGrade B 8 pointsGrade C 7 pointsGrade D 6 pointsGrade E 5 pointsGrade F 0 pointsThe program should input the number of subjects, followed by the grade obtained in each subject. The program should calculate the average of the grade points and print it.arrow_forwardA palindromic number is a number that is the same when written forwards or backwards. The first few palindromic numbers are therefore are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 111, 121, 323 Input a number from the user. Write a program that reverses the digits of a number. Use this program to find if the number is a palindrome. Print if the number is palindrome or not.arrow_forwardWrite a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1.You may assume that the string does not contain spaces and will always contain less than 50 characters. Ex: If the input is: n Monday the output is: 1 n Ex: If the input is: z TodayisMonday the output is: 0 z's Ex: If the input is: n It'ssunnytoday the output is: 2 n's Case matters. Ex: If the input is: n Nobody the output is: 0 n's n is different than N. C LANGUAGE PLEASEarrow_forward
- using py3arrow_forwardWrite a program that reads student scores, gets the best score, and hence assigns grades based on the following scheme: Grade is A if score is > = best - 10; Grade is B if score is > = best - 20; Grade is C if score is > = best - 30; Grade is D if score is > = best - 40; Grade is F otherwise. The program prompts the user to enter the total number of students, then prompts the user to enter all of the scores, and concludes by displaying the grades. Language: C++arrow_forwardf. A laborant in a laboratory does a number of antigen tests in one day. Write a program that simulates the number of antigen tests done in a day in a laboratory, displays the number of positives and negatives, and calculates the % of positives in one day. Your program needs to first generate a random number that will show the number of tests done in a day. One laboratory in a day cannot do more than 100 tests and less than 1 (they do at least one). Then for each of the tests, your program needs to generate a random number to show whether they are positive or negative. In order to write this program, you need to have the following three functions used by the main function: test result (void): This function generates a test result. It should randomly return either one or zero. 1 means positive test result and 0 means negative test result. float positive percentage (int,int) : This function takes the total number of positives and the total number of tests and returns the % of positives.…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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY