Concept explainers
Write a
Enter time in 24-hour notation: 13:07 That is the same as 1:07 PM Again?(y/n) y Enter time in 24-hour notation: 10:15 That is the same as 10:15 AM Again?(y/n) y Enter time in 24-hour notation: 10:65 There is no such time as 10:65 Try again: Enter time in 24-hour notation: 16:05 That is the same as 4:05 PM Again?(y/n) n End of program |
You will define an exception class called TimeFormatMistake. If the user enters an illegal time, like 10:65 or even gibberish like 8&*68, then your program will throw and catch a TimeFormatMistake.
Trending nowThis is a popular solution!
Chapter 16 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Modern Database Management
Electric Circuits. (11th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
Mechanics of Materials (10th Edition)
- Write a program that calculates the equivalent resistance of a circuit. n electrical resistors with resistance values R1, R2,.., Rn are said to be connected in parallel if the same voltage is applied across each. Their equivalent resistance Reg is related to the values R1, R2, ..., Rn by: 1 1 1 1 + +...+ R R R, R. "eq Write a program that prompts the user to enter the resistance of n resistors. The user should be prompted continuously by using a while loop until a zero or negative value is entered (the program should count the number of resistors n entered by the user and store the values in an array). Use another separate loop to print the resistance values entered by the user and the equivalent resistance Reg. Test your program with R1= 1 kn, R2= 2 kn, R3= 4 kQ and R4= 8 kQ.arrow_forwardRead and understand the following problem: 1. Write a program that accepts from the user an amount in Peso. It should compute the equivalent amount in HK dollar, US dollar and Canadian dollar. Display the amount in Peso and the equivalent amount in the different currencies. Given: 1 HK dollar = Php 6.51 1 US dollar = Php 50.68 1 Can. Dollar = 40.06 note: discuss or explain the solution of the problemarrow_forwardWrite a program that asks users when their birthday is. Use information provided to give them their astrological sign. Each of the twelve signs should display a different horoscope. Use the following dates for each sign, keeping in mind that both month and day must be evaluated for an accurate result. Aries: March 21–April 20 Taurus: April 21–May 21 Gemini: May 22–June 21 Cancer: June 22–July 22 Leo: July 23–August 22 Virgo: August 23–September 23 Libra: September 24–October 23 Scorpio: October 24–November 22 Sagittarius: November 23–December 21 Capricorn: December 22–January 20 Aquarius: January 21–February 19 Pisces: February 20–March 20arrow_forward
- Write a program that takes in an integer in the range 11-100 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical. Ex: If the input is: 93 the output is: 93 92 91 90 89 88 Ex: If the input is: 11 the output is: 11 Ex: If the input is: 9 or any value not between 11 and 100 (inclusive), the output is: Input must be 11-100 this is what i have n = int(input())if n > 100 or n < 11:print('Input must be 11-100')exit(0)while True:print(n, end=" ")first_digit = n // 10second_digit = n % 10 if first_digit == second_digit:break n = n-1 my output is 93 92 91 90 89 88 but it needs to be 93 92 91 90 89 88arrow_forwardWrite a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. For division, if the denominator is zero, output an appropriate message. Limit the supported operations to + -/ *and write an error message if the operator is not one of the supported operations. Here is some example output: 3 + 4 = 7 13 * 5 = 65 C++arrow_forwardWrite 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_forward
- Write a program which can be used to calculate bonus points to given scores in the range [1..9] according to the following rules: If the score is between 1 and 3, the bonus points is the score multiplied by 10 If the score is between 4 and 6, the bonus points is the score multiplied by 100 If the score is between 7 and 9, the bonus points is the score multiplied by 1000 For invalid scores there are no bonus points (0) Your program must make use of 2 parallel arrays - one to store the scores and the other to store the bonus points. You need to make provision for 5 scores (and bonus points) that will need to be stored. For this program implement the following methods and use these methods in your solution (do not change the method declarations): static void getScores(int[] scores) \\ gets the required scores from the user - no checking for valid entries \\ you may assume valid values static void calc Bonus(int[] scores, int[] bonusPoints) \\ calculates the bonus points and stores them in…arrow_forwardWrite in symbolic form:For all integers x,there exists an integer y such that the sum of x and y equals 0.Write in symbolic form:arrow_forwardWrite a program that generates a random two-digit integer. The program prompts the user to predict the generated number by entering a two- digit integer, and then determines the accuracy of the user’s prediction according to the following rules:If the user’s prediction matches the generated number exactly, the accuracy is 100%. If one digit in the user’s predicted number matches a digit in the gener- ated number, the accuracy is 50%. If none of the digits in user’s predicted number matches with the generated number, the accuracy is 0%.arrow_forward
- use c languagre program.arrow_forwardWrite a program that will calculate and print out bills for the city water company. The water rates vary depending on whether the water is for home use, commercial use or industrial use. A code of H means home use, a code of c means commercial use and a code of I means industrial use. The water rates are computed as follows: code H: P250.00 plus P0.002 per gallon used code c: P5,000.00 for the first 4 million gallons and P0.002 for each additional gallon. code I: P8,000 if usage does not exceed 4 million gallons, P14,000 if usage is more than 4 million gallons but not more that 10 million gallons and P18000 if usage exceeds 10 million gallons. Your program should prompt the user for the code and the gallons of water used. Your program should echo your input data and should print the amount due from the user. Your program should use a switch statement for the code (char data type). Use the float data…arrow_forwardTask 9 Write Python code of a program that reads an integer, and prints the integer if it is a multiple of NEITHER 2 NOR 5. For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 ... hint(1): use the modulus (%) operator for checking the divisibility hint(2): You can consider the number to be an integer !%3%===== Example01: Input: 3 Output: 3arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning