Write a program that reads a mobile phone number and validates it. If it is valid,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that reads a mobile phone number and validates it. If it is valid, the program simply prints the phone number. Hint: Mobile phone numbers in Kuwait are 8 digits and start with 5, 6 or 9. Desired output format: (user input is underlined) Enter your mobile number: 123. Invalid number! Please re-enter: 56789 Invalid number! Please re-enter: 55219874 Thank you! Your phone number is: 55219874 Enter your mobile number: 987654 Invalid number! Please re-enter: 98765432 Thank you! Your phone number is: 98765432 Exercise 2: Write a program that reads as input your date of birth. It should validate it as follows: day (1-30), month (1-12) and year (1900-2019). If the date is valid, print it in this format: day-month-year. Desired output format: (user input is underlined) Enter your day of birth: 52 Invalid day! Please re-enter: 25 Enter your month of birth: 13 Invalid month! Please re-enter: 14 Invalid month! Please re-enter: 10 Enter your year of birth: 2020 Invalid year! Please re-enter: 1850 Invalid year! Please re-enter: 1980 Thank you! Your date of birth is: 25-10-1980 Exercise 3: Write a program that reads the number of items n in a receipt. It should then ask the user to enter the n prices of those items and validate each price is in [0-1000]. Finally, it prints the sum of the bill. Desired output format: (user input is underlined) Enter the no. of items: 5 Enter item's price: 20 Enter item's price: 40 Enter item's price: 1222 Error: price should be 0-1000. Re-enter item's price: 60 Enter item's price: 5 Error: price should be 0~1000. Re-enter item's price: 40 Enter item's price: 30 The bill's total is: 190 Write a program that reads a mobile phone number and validates it. If it is valid, the program simply prints the phone number. Hint: Mobile phone numbers in Kuwait are 8 digits and start with 5, 6 or 9. Desired output format: (user input is underlined) Enter your mobile number: 123. Invalid number! Please re-enter: 56789 Invalid number! Please re-enter: 55219874 Thank you! Your phone number is: 55219874 Enter your mobile number: 987654 Invalid number! Please re-enter: 98765432 Thank you! Your phone number is: 98765432 Exercise 2: Write a program that reads as input your date of birth. It should validate it as follows: day (1-30), month (1-12) and year (1900-2019). If the date is valid, print it in this format: day-month-year. Desired output format: (user input is underlined) Enter your day of birth: 52 Invalid day! Please re-enter: 25 Enter your month of birth: 13 Invalid month! Please re-enter: 14 Invalid month! Please re-enter: 10 Enter your year of birth: 2020 Invalid year! Please re-enter: 1850 Invalid year! Please re-enter: 1980 Thank you! Your date of birth is: 25-10-1980 Exercise 3: Write a program that reads the number of items n in a receipt. It should then ask the user to enter the n prices of those items and validate each price is in [0-1000]. Finally, it prints the sum of the bill. Desired output format: (user input is underlined) Enter the no. of items: 5 Enter item's price: 20 Enter item's price: 40 Enter item's price: 1222 Error: price should be 0-1000. Re-enter item's price: 60 Enter item's price: 5 Error: price should be 0~1000. Re-enter item's price: 40 Enter item's price: 30 The bill's total is: 190
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Takeaways for Case study analysis of Transferring Knowledge Between Projects at NASA JPL
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Consider a post office with two employees and a single waiting line. On average, the inter-arrival time is 6 minutes. Standard deviation of inter-arrival time is 3.94 minutes. Average service time is...
-
The beam AB supports two concentrated loads and rests on soil that exerts a linearly distributed upward load as shown. Determine the values of (A and (B corresponding to equilibrium. 24 kN 30 kN...
-
Identify the functions represented by the following power series. 8 x2k k=1 k
-
Referring to Example 1, use \(q_{0.05}=3.776\) for the Tukey HSD method to examine differences in mean coating weights. Data From Example 1 EXAMPLE I Conducting a one-way analysis of variance To...
-
Alquist Company uses the retail method to estimate its ending inventory . Selected information about its year 2011 operations is as follows: a. January 1, 2011, beginning inventory had a cost of...
-
Two sole proprietorship businesses converted to partnership. No revaluation of assets and liabilities required. Lourdes and Bernadette individually have been in the catering service business for...
-
The movie below shows some molecules in a tiny sample of a mixture of gases. 078 11 12 13 14 15 16 17 18 19 20 IIIIIIH Drag the slider to see how the molecules move. Does a chemical reaction happen...
-
Describe the guidelines for developing an effective group sales presentation.
-
What is the purpose of the statement of changes in equity (net assets)?
-
What role do salespeople play in positioning a product for competitive advantage?
-
List and describe the criteria for evaluating sales performance.
-
Describe the dimension of consideration as a leadership style. What are the typical behaviors of a sales manager who exemplifies this style?
-
You are assigned the design of a cylindrical, pressurized water tank for a future colony on Mars, where the acceleration due to gravity is 3.71 meters per second per second. The pressure at the...
-
Which provision could best be justified as encouraging small business? a. Ordinary loss allowed on $ 1244 stuck. b. Percentage depletion. c. Domestic production activates deductions. d. Interest...
-
Suppose that you have a binary file that contains numbers whose type is either int or double. You dont know the order of the numbers in the file, but their order is recorded in a string at the...
-
Create a class SchoolKid that is the base class for children at a school. It should have attributes for the childs name and age, the name of the childs teacher, and a greeting. It should have...
-
Write a program that will read a line of text as input and then display the line with the first word moved to the end of the line. For example, a possible sample interaction with the user might be...
-
E = 0.05. Estimate the minimum sample size needed to achieve the given margin of error.
-
Figure 9 shows a histogram for a random sample of n = 264 women (drawn from the same NHANES III study used for the sample of men in Figure 6). The mean of these data is x = 59.6 grams and the...
-
Consider the distribution of sample proportions shown in Figure 5. Suppose you randomly select the following sample of 32 responses: Compute the sample proportion, p, for this sample. How far does it...
Study smarter with the SolutionInn App