Write a
Please enter the first time: 0900
Please enter the second time: 1730
8 hours 30 minutes
Extra credit if you can deal with the case where the first time is later than the second:
Please enter the first time: 1730
Please enter the second time: 0900
15 hours 30 minutes
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Big Java Late Objects
Additional Engineering Textbook Solutions
Computer Science: An Overview (12th Edition)
Starting Out with C++: Early Objects (9th Edition)
Data Structures and Algorithms in Java
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Problem Solving with C++ (9th Edition)
- Write a program that takes a positive integer as the height of the triangle and prints an alphabetical triangle, using lowercase English letters as shown below. Each subsequent row of the triangle should increase in length by two letters. Make sure your program validates the user input. If the user does not input a positive integer, print "Invalid input."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_forwardWrite a program that prompts the user to enter the month and first day of the month, and displays all the Sundays in that month. For example, if the user entered the month 7 for July, and the first day 4 for Wednesday, your program should display the following output:arrow_forward
- Write a program that reads the employee's name and base salary and then calculates the tax and net amount Salary where: Net salary = Basic salary If the basic salary is less than 500 (no tax) Net salary = basic salary - tax value So that the tax amount is 5% of the basic salary Then it prints the employee's name and net salary %3D 2:40 PM /arrow_forwardA parking garage charges a $20.00 minimum fee to park for up to three hours. The garage charges an additional $5.00 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24- hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and printsthe parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday’s receipts. The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format: Car Hours Charge1 1.5 20.002 4.0…arrow_forwardStatistics are often calculated with varying amounts of input data. Write a program that prompts for and takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Example program run (the user types only the numbers, in this case 15 20 0 5 -1): Enter numbers separated by spaces, with a negative number to quit: 15 20 0 5 -1 Average = 10 Max = 20 #include <iostream>using namespace std;/* program that prompts for and takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Example program run (the user types only the numbers, in this case 15 20 0 5 -1): Enter numbers separated by spaces, with a negative number to quit:15 20 0 5 -1 Average = 10 Max = 20*/ int main() { /* Type your code here. */ return 0;}arrow_forward
- Coral Help Write a program that takes a date as input and outputs the date's season. The input is an integer to represent the month and an integer to represent the day. Ex: If the input is: 4 11 the output is: spring In addition, check if both integers are valid (an actual month and day). Ex: If the input is: 14 65 the output is: invalid The dates for each season are:spring: March 20 - June 20summer: June 21 - September 21autumn: September 22 - December 20winter: December 21 - March 19arrow_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 that repeatedly asks the user to enter integer numbers (validation is not necessary). The program should continue to read numbers from the user until they enter a negative number (e.g., 3, 7, 3, 1, 6, 4, -1). Once the user enters a negative number, the program should stop repeating the prompt and print out the second largest number that the user has entered. You can assume the user will enter at least two non-negative (non-zero) numbers. Note: you may not use lists or other summary functions (max, min, etc.) for this problem. You should only need input/variables/looping/branching structures.Example:Enter positive integers: 3, 7, 3, 1, 6, 4, -1 The second largest number is: 6arrow_forward
- You are asked to write a program that calculates your electric bill. You are to input the numberof kilo-watt hours (kWh) used in a 31 day billing period. Electricity costs 6.72 cents per kWh; atax of 8% should be added. Write a program that accepts the number of kilo-watt hours usedand prints a bill.Sample Run:Please enter the kilo watt hours over 31 days: 412Electric bill for a 31 days period is as follows:Number of Kilo Watt hours: 412.0Amount: $27.6864 Tax: $2.214912Total: $29.901311999999997arrow_forwardWrite a program that reads from the user a number that represents its grade, and then displays a message to tell the user if he passed the exam (if the entered grade is greater than or equal to 60) or not (if the entered grade is less than 60). The entered grade should be a number between 0 and 100. Otherwise, the program displays an error message. Sample Run: Please enter your grade (between 0 and 100): 75 Congratulations! You have passed the exam. Please enter your grade (between 0 and 100) : 45.5 Unfortunately... You have not passed the exam. Please enter your grade (between 0 and 100) : 112 ERROR: You have entered a wrong grade!arrow_forwardWrite 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? Iarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning