Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer Science A painting company wants a program to print the cost of painting based on the size of the room. Writea program that prompt

Computer Science

A painting company wants a program to print the cost of painting based on the size of the room. Writea program that prompt the user to enter the length and width of the room in meter, and the date and time of the transaction. Your program should accept the time in 24-hour notation. Then convert it to the 12-hour notation. Accept the time as two integers; one for hour and the other for minutes. The date will be accepted as month number, day number, and year as a 4-digit number (dd mm yyyy). You don't need to accept dash or slash as part of the date. But remember, for any format that your program accepts, you should inform the user within the prompt sentence. Calculations: Your program should calculate the total square meter of the room including 4 walls and one ceiling, the number of cans of paint (note: if a room, for example, needs 2.5 cans of the paint you should assume it as 3 cans), and the cost of the paint. The height of a room is 3 meters, and the price of a can of paint is $15.50. A one-gallon can of paint covers 20 square meter. Also, your program should convert the 24-hour notation into 12-hour notation. And find the day of the week that corresponds to the transaction date. For example, if the transaction date is on 1/24/2022, your program should find it as Monday. For finding the day of the week please see the programming project 7 on page 300 of your textbook. Output: The program should loop until the user enters 0 for length. Use the pretest while structure. The loop structure should be part of the main function. The program includes the following functions: Be sure to use the function names provided. Do not change the specifications for the functions. displayTitle This function displays a title for the window. displayTitle is an example of a void function. getData This function displays a prompt requesting the value for the length. If 0 is not entered for the length, the function displays a prompt requesting the width. This function is a call-by-reference since it needs to supply main with values. convert12Format This function receives the hour and convert it to 12-hour notation. For a 12-hour notation you need to return a character as well (A for AM and P for PM). So, this function is call by reference too. The rest of the functions are call-by-value. Do not use call call-by-reference. calcSqMeter This function receives the values for length and width, and calculates the square meter including the ceiling. The function returns an integer to main. calcTotalCans This function calculates and returns the number of cans needed rounding up to the next whole number. calcCost This function calculates and returns the total cost. displayResults This function receives the numeric results to display. Note how the decimals are aligned for readability in the sample run. isLeapYear This function should return true if year is a leap year and false if it is not. getYearValue This function computes a value based on the years since the beginning of the century. getMonthNumber This function returns a month number based on the three-digit month name. getMonthVa0lue This function should return a value based on the table on textbook page 302 and will require invoking the isLeapYear function. dayOfWeek This function returns the day of the week of the specified date as an int (Sunday = 0, Monday = 1, etc.) displayMsg This function displays a message reporting a free gift based on the number of cans purchased. Be sure to use a nested if. The customer only receives one free gift. 1 - 3 cans - free paint brush. 4-7 cans - free paint tray. More than 7 cans - $10 gift card. Sample Output:

Rainbow Printing Company

Paint Costing

--------------------------------------------------------------------------------

Enter the length in meter (0 to stop).....4

Enter the width in meter........................5

Enter the transaction time in 24-hour notation:

Hour:16

Minute:35

Enter the transaction date (dd mm yyyy):2 21 2022

--------------------------------------------------------------------------------

Area = 74 Square meters

Cans = 4

Cost = 62.00

Date/Time: Monday, February 21, 2022 4:35 PM

Gift: Free paint tray

Thank you for your purchase.

==============================================

Enter the length in meter (0 to stop)...

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Vector Mechanics for Engineers Statics and Dynamics

Authors: Ferdinand Beer, E. Russell Johnston Jr., David Mazurek, Phillip Cornwell, Brian Self

11th edition

73398241, 978-0073398242

More Books

Students also viewed these Programming questions