Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
January 30th, 2013, 09:00 AM
 nisal500
Registered User

Join Date: Jan 2013
Posts: 2
Time spent in forums: 36 m 36 sec
Reputation Power: 0
C Programming question Urgent (Plz help meeeeeeee)

1)In an Internet Café customers are charged as follows for browsing:
• First hour or part of an hour – 40 Rupees
• Next four hours – 30 Rupees per hour or part of an hour
• For each hour after that – 20 Rupees per hour or part of an hour
Write a C program using the “Else-If” statement such that when the user enters the number of hours of Internet Connection, the program displays the amount to charge from the customer.
Example: If a user browsed the Internet 3 hours and 15 minutes,
Charge = 40 Rs for the 1st hr+30*3 Rs for the next 2 hr and 15 min

2)A shop sells electrical appliances such as TVs, Fridges, Fans, and Washing Machines etc. In case the customers cannot pay the full amount to purchase an appliance the shop supports easy payment schemes, such that the customers can make the payments via monthly installments.
Four payment schemes are supported as given below:
Scheme Payment Duration No. of Installments Interest Rate %
1 6 months 6 6
2 1 year 12 8
3 1.5 years 18 10
4 2 years 24 12

Monthly Installment = (Price of the Appliance + Interest) / No. of Installments
Example: A customer buy a TV worth of 60 000 Rs, and agree to make the payments with in 1 year. i.e. The customer had selected the 2nd payment scheme.
Monthly Installment = (60 000 + (60 000*8/100)) / 12 = 5400 Rs.
Write a C program that calculates and display the value monthly installment when the user input the price of the appliance and the payment scheme. Use the “Switch” statement.

Plz help me my exams are near .

#2
January 30th, 2013, 09:08 AM
 salem
Contributed User

Join Date: Jun 2005
Posts: 4,261
Time spent in forums: 2 Months 4 Weeks 1 Day 15 h 29 m 23 sec
Reputation Power: 1827
No, we will not do your homework for you
You make an effort, then we advise you on what you did right/wrong, and how to proceed towards a solution.

At the very least, for each program you should be able to
- print a prompt

Perhaps when you've got some data sitting in front of you, the next step might be clear enough to have a go at at least.

> Plz help me my exams are near
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

#3
January 30th, 2013, 10:11 AM
 nisal500
Registered User

Join Date: Jan 2013
Posts: 2
Time spent in forums: 36 m 36 sec
Reputation Power: 0
You make an effort, then we advise you on what you did right/wrong, and how to proceed towards a solution.

At the very least, for each program you should be able to
- print a prompt

Perhaps when you've got some data sitting in front of you, the next step might be clear enough to have a go at at least.

> Plz help me my exams are near

I just did the 2nd question but cant get the correct output.
#include<stdio.h>
int main()
{

int scheme,ins,rate;
float dur,price;
float monthly;
printf("Price of the equipment \n");
scanf("&f",&price);

printf("WHAT IS UR PAYMENT DURATION in years \n");
scanf("&f",&dur);

if(dur==0.6){scheme=1;}
else if(dur==1){scheme=2;}
else if(dur==1.5){scheme=3;}
else if
(dur==2){scheme=4;}

switch (scheme)
{
case '1' : monthly=price+(price*6/100)/6;
printf("Monthly installment is %f",monthly);
break;
case '2' : monthly=price+(price*8/100)/12;
printf("Monthly installment is %f",monthly);
break;
case '3' : monthly=price+(price*10/100)/18;
printf("Monthly installment is %f",monthly);
break;
case '4' : monthly=price+(price*12/100)/24;
printf("Monthly installment is %f",monthly);
break;

return 0;

}

}

#4
January 30th, 2013, 10:35 AM
 salem
Contributed User

Join Date: Jun 2005
Posts: 4,261
Time spent in forums: 2 Months 4 Weeks 1 Day 15 h 29 m 23 sec
Reputation Power: 1827
> scanf("&f",&price);
> scanf("&f",&dur);
The format character is %, not &
As in
scanf("%f",&price);

> if(dur==0.6){scheme=1;}
> ..
> case '1' : monthly=price+(price*6/100)/6;
Make your mind up as to whether it's 1 or '1'.
Either will do, so long as you're consistent about it.

Also, use [code][/code] tags when posting code.

 Viewing: Dev Shed Forums > Programming Languages > C Programming > C Programming question Urgent (Plz help meeeeeeee)