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

  C program to calculate power loss in transmission line

Write program in C to calculate the power loss in transmission line with resistance of 0.05 ohms/mile. Calculate power loss if 500 kW of power is transmitted from power generation station

  Write a program to print the permutation

Write a program to print the permutation that lexicographically precedes the given input permutation.

  Write a function that takes two positive integer arguments

Write a function named "g_c_d" that takes two positive integer arguments and returns as its value the greatest common divisor of those two integers. If the function is passed an argument that is not positive (i.e., greater than zero).

  Design and implement a c program and structure diagram for

design and implement a c program and structure diagram for the subsequent specification.show writing and calling

  A program computes and displays the number of centimeter

The Earth's ocean levels have risen an average of 1.8 millimeters per year over the past century. Write a program computes and displays the number of centimeters and number of inches the oceans rose during this time.

  Create a simple command line program that simulates

Instructions:  Create a simple command line program that simulates the rolling of a pair of six sided dice a user given number of times

  Write a program to find solutions to the n-queens puzzle

Write a program to find solutions to the n-queens puzzle for various valuesof n. To be specific, test your program for n =4 and n =8.

  Write a value-returning function

Write a program that uses the function isNumPalindrome given(Palindrome Number). Test your program on the following numbers: 10, 34, 22, 333, 678, 67876, 44444, and 123454321.

  The two major modifications are the instruction of pointers

the two major modifications are the instruction of pointers and the calculation of mortgage interest rates.requirements

  Same birthday

How likely is it that two people in one section of our class (40 students) have the same birthday ?

  Write a script that creates a craps game

Write a script that creates a craps game and meets the following requirements. Name the script craps.sh The script will get 2 random numbers between 1-6.

  Given the following test scores and grade equivalents

Given the following test scores and grade equivalents, write a function which is passed a score, and returns a letter grade based on the score entered. A number less than 0 or greater than 100 is invalid.

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