### Thread: Need urgent help on C programming.

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

Join Date
Nov 2012
Posts
3
Rep Power
0

#### Need urgent help on C programming.

Just realize that i need to submit the assignment in 3 days time and my brother getting married tomorrow. Really don't have time to do my assignment. Appreciate if anybody can help. Just a simple C programming for both questions below are really much helpful... Really2 need help...

QUESTION 1

Write a C program that will calculate and print out the bills for the city water company. The water rates vary, depending on whether the bill is for home use, commercial use, or industrial use. A code of h means home use, a code of c means commercial use, and a code of i means industrial use. Any other codes should be treated as an error. The water rates are computed as follows:

Code h: RM5.00 plus RM0.0005 per gallon used
Code c: RM1000.00 for the first 4 million gallons used and RM0.00025 for each additional gallon
Code i: RM1000.00 if usage does not exceed 4 million gallons; RM2000.00 if usage is more than 4 million gallons but does not exceed 10 million gallons; and RM3000.00 if usage exceeds 10 million gallons

Your program should prompt the user to enter an account number (type int), the code (type char) and the gallons of water used (type double). Your program should echo the input data and print the amount due from the user.

QUESTION 2

Bunyan Lumber Company needs to create a table of the engineering properties of its lumber. The dimensions of the wood are given as the base and the height in inches. Engineers need to know the following information about lumber:

The owner makes lumber with base sizes of 2, 4, 6, 8 and 10 inches. The height sizes are 2, 4, 6, 8, 10 and 12 inches. Produce a table with appropriate headings to show these values and the computed engineering properties. The first part of the table’s outline is shown as follow:

Lumber Size Cross-Sectional Area Moment of Inertia Section Modulus
2 x 2
2 x 4
2 x 6
2 x 8
2 x 10
2 x 12
4 x 2
4 x 4
.
.
.
2. Notes on Homework
Notes on urgency
It shouldn't take you more than 1/2 day to do both of them, so go enjoy your party and then buckle down to some serious work at the weekend.

Post your best effort with at least 1/2 day to go, then we can work out what you need to fix.

Just don't leave it too late with like 2 hours to go expecting a miracle.

Edit:
Now that's a shocker!
cross-post-mania
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
3
Rep Power
0
Only able to do the 1st question..but got syntac error. No sure where's the problem.

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

main ()

{
int a, b, e, account;
double gallon, total1, total2;
char selection, h, c, i;

printf("Below are the type of places that covered by city water company.\n");
scanf("%d", &account);
printf("Press <h> for House use.\n");
printf("Press <c> for Commercial use.\n");
printf("Press <i> for Industrial use.\n");
printf("Please specify the type of place:");
scanf("%c %c %c", h, c, i);

if(selection=h)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);

a=gallon*0.0005;
total1=a+5;

printf("The total bill is:");
scanf("%f", &total1);

Z else if(selection=c)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);

b=gallon-4000000;
e=b*0.00025;

total2=1000+e;

printf("The total bill is:");
scanf("%f", &total2);

else if(selection=i)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);
{

if(gallon<4000)
printf("The total bil is: RM1000");

else if(gallon>4000000 & gallon<10000000)
printf("The total bil is: RM2000");

else if(gallon>1000000)
printf("The total bil is: RM3000");

else
printf("Not been billed");
}

else
print("You have enter wrong code");

getch();
return (0);

}

and for the second question. got stucked. really need help for function.
4. If you don't want to do the work, then either take the hit or drop the class. Aiding you in committing plagiarism, a crime which will get you expelled from school, is not an option.

If you need help with problems you encounter while doing your own homework, then we are more than happy to help. But we don't support plagiarism.
5. Originally Posted by jebart_sttj98
Only able to do the 1st question..but got syntac error. No sure where's the problem.
Problem? What problem? What makes you think there's a problem?

IOW, describe the problem to us. You wouldn't withhold your symptoms from your doctor, would you? So why do it to us?

Also, post your code in code tags; eg:

Code:
```#include <stdio.h>
#include <math.h>
#include <stdlib.h>

main ()

{
int a, b, e, account;
double gallon, total1, total2;
char selection, h, c, i;

printf("Below are the type of places that covered by city water company.\n");
scanf("%d", &account);
printf("Press <h> for House use.\n");
printf("Press <c> for Commercial use.\n");
printf("Press <i> for Industrial use.\n");
printf("Please specify the type of place:");
scanf("%c %c %c", h, c, i);

if(selection=h)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);

a=gallon*0.0005;
total1=a+5;

printf("The total bill is:");
scanf("%f", &total1);

Z       else if(selection=c)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);

b=gallon-4000000;
e=b*0.00025;

total2=1000+e;

printf("The total bill is:");
scanf("%f", &total2);

else if(selection=i)
printf("Please enter the total gallon used:");
scanf("%f", &gallon);
{

if(gallon<4000)
printf("The total bil is: RM1000");

else if(gallon>4000000 & gallon<10000000)
printf("The total bil is: RM2000");

else if(gallon>1000000)
printf("The total bil is: RM3000");

else
printf("Not been billed");
}

else
print("You have enter wrong code");

getch();
return (0);

}```
That stray "Z" isn't going to do any good. Also, you need to enclose a multi-statement block of code in braces.

Read your compiler error messages. Also be sure to turn warnings on and do not ignore the warnings! Warnings are much more important than errors.

And on the second one, if you have a question, then ask it! We're not mind-readers!
6. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Nov 2012
Posts
3
Rep Power
0
ok.. thanks for the advise.. will try to do the question 2.. once finish i'll send both answers to be check... thanks again..