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++ (9th Edition)
Additional Engineering Textbook Solutions
Modern Database Management
Absolute Java (6th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- 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_forward. Write a program that generates and prints 50 random integers, each between 3 and 6. .Write a program that generates a random number, x, between 1 and 50, a random number y between 2 and 5, and computes x". .Write a program that generates a random number between 1 and 10 and prints your name that many times. .Write a program that generates a random decimal number between 1 and 10 with two decimal places of accuracy. Examples are 1.23, 3.45, 9.80, and 5.00.arrow_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_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_forwardWrite 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_forward
- Write 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_forwardA supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest. Make a program to calculate this. Input The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full. Output For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer.arrow_forward
- in the United States, telephone numbers consist of a three digit area code followed by a seven digit local number. Suppose neither the first digit of an area code nor the first digit of a local number can be a zero but that all other choices are acceptable. do not use commas when you write your number. For example enter 3356789 NOT 3,456,789arrow_forwardWrite a program that accepts the names of three political parties and the number of votes each received in the last mayoral election. Display the percentage of the vote each party received. An example of the program is shown below: Enter name for first party >> Pool Party Enter votes received >> 87 Enter name for second party >> House Party Enter votes received >> 54 Enter name for third party >> Surprise Party Enter votes received >> 111 The Pool Party party got 34.523809523809526 percent of the vote The House Party party got 21.428571428571427 percent of the vote The Surprise Party party got 44.047619047619044 percent of the votearrow_forward..5-- I have a python programing question In 1937, a German mathematician named Lothar Collatz formulated an intriguing hypothesis (it still remains unproven) which can be described in the following way: 1. take any non-negative and non-zero integer number and name it c0; 2. if it's even, evaluate a new c0 as c0 ÷ 2; 3. otherwise, if it's odd, evaluate a new c0 as 3 × c0 + 1; 4. if c0 ≠ 1, skip to point 2. The hypothesis says that regardless of the initial value of c0, it will always go to 1. Of course, it's an extremely complex task to use a computer in order to prove the hypothesis for any natural number (it may even need artificial intelligence), but you can use Python to check some individual numbers. Maybe you'll even find the one which would disprove the hypothesis. Write a program which reads one natural number and executes the above steps as long as c0remains different from 1(c0 != 1). Moreover, we'll add another task - we want you to count the steps needed to achieve the goal.…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning