Write a program that allows a user to enter a string containing a day of the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that allows a user to enter a string containing a day of the week ("Sunday," “Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20 Write a program that allows a user to enter a string containing a day of the week ("Sunday," “Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20 Write a program that allows a user to enter a string containing a day of the week ("Sunday," “Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20 Write a program that allows a user to enter a string containing a day of the week ("Sunday," “Monday," "Tuesday," etc.) and uses a switch construct to convert the day to its corresponding number, where Sunday is considered the first day of the week and Saturday is considered the last day of the week. Print out the resulting day number. Also, be sure to handle the case of an illegal day name! (Note: Be sure to use the 's' option on function input so that the input is treated as a string.) Your result should look like >> inclass2 Enter the day of the week: Thursday Thursday is day 5 of the week. >> inclass2 Enter the day of the week: Weekend Invalid day entered. 20
Expert Answer:
Answer rating: 100% (QA)
TestCodem day inputEnter day of week s switch day case Sund... View the full answer
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these mechanical engineering questions
-
Write a program that allows the user to input 15 grades that range from 0 - 100. If the user inputs a number larger than 100 or small than 0, then the program should tell the user that they entered...
-
Write a program that allows the user to enter time in seconds in the text field and press the Enter key to count down the seconds, as shown in Figure 16.45d. The remaining seconds are redisplayed...
-
Write a program that allows the user to enter his or her name. The program should output a username for entry into a website. The user should be prompted to enter a first name, middle initial, and...
-
What is a derivative contract? Give an example. How are derivatives related to risk management?
-
Locate a person who is about to make a major purchase. Ask that person to make a chronological list of all the information sources consulted before` making a decision. How would you characterize the...
-
Evaluate each of the following expressions to six-figure accuracy. (1.0083)30-1 0.0083
-
The owner of an ice cream store asks 75 people which flavor of ice cream they prefer. Thirteen of them say strawberry, 11 say chocolate, 24 say vanilla, and 27 provide a flavor other than strawberry,...
-
Kristin Simon needs to borrow $4,000. First State Bank will lend her the money for 12 months through a single-payment loan at 8 percent, discount; Home Savings and Loan will make her a $4,000,...
-
Question 10 of 11 < > -/3 E A Here are comparative financial statement data for Blossom Company and Crane Company, two competitors. All data are as of December 31, 2022, and December 31, 2021....
-
Formulate a linear program which can be used to generate a comprehensive plan for the whole Far Eastern operations. Clearly define every variable used in your formulation. Start your report with an...
-
From the data shown in the figure, which property of an extrasolar planet cannot be determined? a. mass b. orbital distance c. radius d. orbital period e. All of the above properties can be...
-
COS101 HW#7 - Data storage Part 2 1. Convert each of the following base ten representations to its equivalent two's complement representation in which each value is represented in eight bits. Show...
-
public class Class extends ClassA public classB ( ( Time left 0 0 : 1 2 : 0 3 int init = 1 0 ; super ( 4 0 ) ; O a . . The method super is not defined. b . . No values may be passed to super. O c . ....
-
30. (Bonus) The plaintext "BONUS PROBLEM" gets encrypted to "QF434Q6.1FJJXTS", and the Hill Cipher key is nine characters long. Decrypt the message "V.8Y_Q063163.15".
-
You have been given the following algorithm. What does it return? Input: Array A [ 1 . . . [ 1 . . . n ] ] Output: ? ? ? ? out 1 1 for i 2 2 to n do if A [ [ i ] < ] < A [ [ out ] ] then out i return...
-
1. Given the IP address of 172.16.1.1 with a mask of 255.255.255.0-- How many total subnets could be created? (assume all subnets use the same subnet mask) a. 65536 b. 254 c. 256 d. 64 2. Represent...
-
Go to google.com and type "usd peso" in the search bar. You should get the value of the most recent rate with clearly specified units and a graph showing historical values for the rate. The default...
-
How many years will it take a $700 balance to grow into $900 in an account earning 5%?
-
Write a program that prompts the user to enter a year and the first three letters of a month name (with the first letter in uppercase) and displays the number of days in the month. Here is a sample...
-
Write a program that displays the following two tables side by side: Kilometers | Kilometers 1.609 3.218 Miles 1. Miles 12.430 15.538 | 25 14.481 37.290 40.398 9. 10 60 | 65 16.090
-
Use the Complex class introduced in Programming Exercise 13.17 to develop the ComplexMatrix class for performing matrix operations involving complex numbers. The ComplexMatrix class should extend the...
-
What are impediments to planning, both at the beginning of a project and throughout the project?
-
What critical elements are important to support the planning process?
-
Use the example building site plan provided as a basis to plan the layout of the site for the building example project.
Study smarter with the SolutionInn App