- Joined
- Feb 28, 2013
- Messages
- 1,898
Code:
#include <stdio.h>
#include <conio.h>
int main (void)
{
double bp, cp, dp, ep, bm, cm, dm, em;
int casha, cashb, ansb, ansc, ansd, anse, ansf;
printf ("MATERIALS\n");
printf ("-----------------------\n");
printf ("Enter the cost of the following\n");
printf ("Paper: ");
scanf ("%d", &bm);
printf ("Pencil: ");
scanf ("%d", &cm);
printf ("Scissors: ");
scanf ("%d", &dm);
printf ("Eraser: ");
scanf ("%d", &em);
printf ("PURCHASE\n");
printf ("-----------------------\n");
printf ("How many items of the following did you buy?\n");
printf ("Paper: ");
scanf ("%d", &bp);
printf ("Pencil: ");
scanf ("%d", &cp);
printf ("Scissors: ");
scanf ("%d", &dp);
printf ("Eraser: ");
scanf ("%d", &ep);
ansb = (bm * bp)+(cm * cp)+(dm * dp)+(em * ep);
printf ("Solving (%d + %lf)*(%d + %lf)*(%d + %lf)*(%d + %lf)=%lf",&bp, &bm,&cp, &cm,&dp, &dm,&ep, &em, &ansb);
printf ("The total price is : P %d \n", &ansb);
printf ("Enter cash : ", &casha);
scanf ("%f", &casha);
cashb = ansf + casha;
printf ("Total is %f",&cashb);
getch();
return 0;
}
/*%f*/
V2
Code:
#include <stdio.h>
#include <conio.h>
int main ()
{
int bm;
int cm;
int dm;
int em;
double bp;
double cp;
double dp;
double ep;
int ans;
int casha;
int cashb;
printf ("MATERIALS\n");
printf ("-----------------------\n");
printf ("Enter the cost of the following\n");
printf ("Paper: ");
scanf ("%d", &bm );
printf ("Pencil: ");
scanf ("%d", &cm );
printf ("Scissors: ");
scanf ("%d", &dm);
printf ("Eraser: ");
scanf ("%d", &em);
printf ("\nPURCHASE\n");
printf ("-----------------------\n");
printf ("How many items of the following did you buy?\n");
printf ("Paper: ");
scanf ("%d", &bp);
printf ("Pencil: ");
scanf ("%d", &cp);
printf ("Scissors: ");
scanf ("%d", &dp);
printf ("Eraser: ");
scanf ("%d", &ep);
ans = (bm * bp)+(cm * cp)+(dm * dp)+(em * ep);
/*printf ("Solving (%d + %lf)*(%d + %lf)*(%d + %lf)*(%d + %lf)=%lf",&bp, &bm,&cp, &cm,&dp, &dm,&ep, &em, &ans);*/
printf ("The total price is : P %d \n", &ans);
printf ("Enter cash : ", &casha);
scanf ("%f", &casha);
cashb = ans + casha;
printf ("Total is %f",&cashb);
getch();
}
Where did i go wrong
The output must be something like this
MATERIALS
---------------------
Enter the cost of the following:
Paper : 0.25
Pencil : 5.00
Scissors : 25.00
Eraser : 2.50
PURCHASE
---------------------
How many items of the following did you buy?
Paper : 10
Pencil : 3
Scissors : 1
Eraser : 1
THE TOTAL PRICE IS 45.00
Enter Cash : 50.00
Return : 5.00
Please help, i need to submit this assignment on sixth day of july
---
Code:
# include<stdio.h>
# include<conio.h>
# define vat 1.12
int main ()
{
double pac, pec, scc, erc, te, cash, tpac, tpec, tscc, terc, ch, pretotal, postotal, posbtotal, posctotal, vatb;
int pa, pe, sc, er, ti;
printf("MATERIALS\n-------------------------------- \n");
printf("Enter the Cost of the Following:\n");
printf("Paper : ");
scanf("%lf", &pac);
printf("Pencil : ");
scanf("%lf", &pec);
printf("Scissors : ");
scanf("%lf", &scc);
printf("Eraser : ");
scanf("%lf", &erc);
printf("\nPURCHASE\n-------------------------------- \n");
printf("How many items of the following did you buy?\n");
printf("Paper : ");
scanf("%d", &pa);
printf("Pencil : ");
scanf("%d", &pe);
printf("Scissors : ");
scanf("%d", &sc);
printf("Eraser : ");
scanf("%d", &er);
tpac = pa*pac;
tpec = pe*pec;
tscc = sc*scc;
terc = er*erc;
pretotal = tpac+tpec+ tscc + terc;
printf("\nTOTAL : P %.2f\n", pretotal);
printf("Cash : P ");
scanf("%lf", &cash);
postotal = cash - pretotal;
printf("\nChange: P %.2f\n", postotal);
printf("Note: When negative, it means the customer has a credit or he has insufficient money to buy the items\n", postotal);
posctotal=pretotal/vat;
vatb=pretotal-posctotal;
printf("\nPrice before VAT: %.2lf", posctotal);
printf("\nVAT (12%): %.2lf", vatb);
getch();
return 0;
}
Last edited: