Conditional statementsquestion 1 write a program that

Assignment Help C/C++ Programming
Reference no: EM13368791

Conditional Statements

Question 1: Write a program that computes the cost of a long distance call. The cost of the call is determined according to the following rate schedules.

  • A call made between 8:00 AM and 6:00 PM is billed at a rate of 6 rupees per minute.
  • A call made before 8:00 AM or after 6:00 PM is charged at a rate of 3.75 rupees.

According to this schedule, if a call starts at any time between 8:00 AM and 6:00 PM, and it ends after 6:00 PM then it will be charged at the rate of 6 rupees per minute for the time before 6:00 PM and for the rest of the time the rate will be 3.75 rupees per minute. For example if a call starts at 5:55 PM and ends at 6:05 PM then the charges on this call will be 48.75 (30 rupees for first 5 minutes and 18.75 rupees for rest of the time).

 

Similarly if a call starts at the time before 8:00 AM but ends after 8:00 AM then it will be charged at the rate of 3.75 rupees for the time before 8:00 AM and for remaining minutes after 8:00 AM the rate will be 6 rupees per minute. For example if a call starts at 7:49 AM and ends at 8:01 AM the charge on that call will be 47.25 rupees (41.25 for first 11 minutes and 6 rupees for last minute).

The input to the program will consist of the time the call started, and the length of call in minutes. The output will be the cost of call. The time is to be input in 24-hours notation, so the time 1:30 PM is input as 13:30. The time will be input using two variables of type int, one used for hour and other used for minutes. The number of the minutes for length of the call will also be input as a value of type int.      

After completing the program test it for following inputs.

Input

Output

Start time

Length

Cost

8: 21

10

60

17:55

10

 

7:49

12

 

6:00

30

 

8:00

5

 

Question 2: You are required to modify the program written for calculating call charges according to the following schedule.

  • Any call made between 8:00 AM and 6:00 PM, Monday through Friday, is billed at a rate of 6 rupees per minute.
  • Any call made before 8:00 AM or after 6:00 PM, Monday through Friday, is charged at a rate of 3.75 rupees per minute.
  • Any call made on a Saturday or Sunday is charged at a rate of 1.5 rupees per minute.

The modified program will also input the day of the week along with the other inputs. The day of the week will be read as one of the following pairs of character values, which are stored in two variables of type char:

Su                  Tu Th Sa                           We Fr Su

 

The rules for calculating the charges for a call are same as in the previous program with following enhancements.

If a call is started on Friday at 11:55 PM and ends at 12:05 AM on Saturday then the rate of the call will be calculated as cost of call as per schedule on Friday for first 5 minutes, plus the cost of call as per schedule on Saturday for rest of the 5 minutes. Similarly, if a call starts on Sunday at 11:55 PM and ends at 12:05 AM on next day i.e. Monday, then the cost of the call will be calculated as charges as per schedule on Sunday plus the charges as per schedule on Monday.

After completing the program test it for following inputs.

Input

Output

Start time

Length

Day

Cost

8: 21

10

Monday

60

17:55

10

Tuesday

 

7:49

12

Friday

 

6:00

30

Sunday

 

23:55

10

Friday

 

23:51

20

Sunday

 

 

 

 

 

 

Reference no: EM13368791

Questions Cloud

Question 1on january 1 forrester county is holding : question 1.on january 1 forrester county is holding investments for tinsel town valued at 800000 in an investment pool
Business operations management layout design for custom : business operations management layout design for custom bicycle assemblerlayout design paper1 identify the type of
Drivers of negotiationwhat is the significance of goal : drivers of negotiationwhat is the significance of goal setting before a meeting. what could happen if this preparation
Integrative negotiationsyou are an employee and heard about : integrative negotiationsyou are an employee and heard about an opportunity to job shadow in a department that you have
Conditional statementsquestion 1 write a program that : conditional statementsquestion 1 write a program that computes the cost of a long distance call. the cost of the call
Create a 30-second elevator speech pitch where you could : create a 30-second elevator speech pitch where you could sell your most valuable product--you why would people want to
Joseph wellington is a certified fraud examiner cfe and an : joseph wellington is a certified fraud examiner cfe and an active member of the association of certified fraud
Post addresses mary moore the ceo of beta incmary moore the : post addresses mary moore the ceo of beta inc.mary moore the ceo of beta inc. has called a management meeting to
What questions should be ask when evaluating the hypothesis : what questions should be ask when evaluating the hypothesis of a researchwhat questions should be ask when evaluating

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a program that draws a two-dimensional house

Create a program that draws a two-dimensional house seen from the front, the way a child would see it: with a door, two windows, and a roof with a chimney

  Test a function hydroxide that takes a chemical formula

Write and test a function hydroxide that takes a chemical formula as a parameter and returns True if the chemical is a hydroxide (i.e. ends in OH).

  1 prepare a program to read 3 numbers x y z use conditional

1. prepare a program to read 3 numbers x y z. use conditional statement and evaluate values of variables a b and c.

  Contacts class that contains an array

Create a Friend class that contains a first name, last name, a birthday, and a telephone number. Create a Contacts class that contains an array of Friend as well as the owner's name and cell phone Number.

  Preparing a high level language program

Describe the purpose of each step in preparing a high level language program for execution (editing, compiling, linking, and loading).  Include in your description the types of files created with each of the first three steps.?

  Describe the process replace a do...while loop with an equiv

Describe the process you would use to replace a do...while loop with an equivalent while loop. What problem occurs when you try to replace a while loop with an equivalent do...while loop? Suppose you have been told that you must remove a while loop a..

  Assignment 1 boxing amoebadevelop a two dimensional

assignment 1 boxing amoebadevelop a two dimensional interactive game with the following features1.use opengl any

  What is the output

Suppose that x and y are int variables, z is a double variable, and ch is a char variable. Suppose the input statement is.

  Write a program to calculate a person''s net pay

Write a program to calculate a person's net pay after subtracting federal income tax.The program should ask the user to enter the person's name, social security number, gross pay, and the number of dependents.

  Assume that a text file named text1txt contains text

Assume that a text file named text1.txt already contains some text written into it, write a function named vowelwords(), that reads the file text1.txt and create a new file named text2.txt,

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  What is the output of the following code

What is the output of the following code?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd