### Thread: C Programming question Urgent (Plz help meeeeeeee)

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jan 2013
Posts
2
Rep 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 . :confused:
2. 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
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jan 2013
Posts
2
Rep 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. > 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.