
February 15th, 2013, 12:45 PM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 1
Time spent in forums: 53 m 6 sec
Reputation Power: 0
|
|
|
Problem help
Hello everyone, im new to c++ and have been having a hard time getting everything squared off.
I am currently in need of help of this program to calculate sales/discount and it is giving me all sorts of problems.
I need help to align the decimal points also to make the y/n an uppercase do I use toupper()?? if so how?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define DISCOUNT_10 10
#define DISCOUNT_12 12
#define NETTAX 5
int main(void)
{
char customer;
int purchase;
double discount2;
double discounttl;
double salestax;
double purchasettl;
printf("Is customer a teacher (Y/N) ?>");
scanf("%c", &customer);
printf("\nEnter total purchases:>");
scanf ("%d", &purchase);
if (customer == 'Y' && purchase > 100) {
discount2 = purchase * 0.12;
discounttl = purchase * 0.88;
salestax = discounttl * 0.05;
purchasettl = discounttl * 1.05;
printf("\nTotal purchases $%6.2lf\n", double(purchase));
printf("Teacher's discount(%d%%) %6.2f\n", DISCOUNT_12, discount2);
printf("Discounted total %6.2f\n", discounttl);
printf("Sales tax(%d%%) %6.2f\n", NETTAX, salestax);
printf("Total %6.2f\n", purchasettl);
}
if (customer == 'Y' && purchase < 100)
{
discount2 = purchase * 0.10;
discounttl = purchase * 0.90;
purchasettl = discounttl * 1.05;
}
printf("\nTotal purchases $%6.2lf\n", purchase);
printf("Teacher's discount (%d%%) %6.2lf\n", DISCOUNT_10, discount2);
printf("Discounted total %6.2lf\n", discounttl);
printf("Sales tax(5%) %6.2lf\n", NETTAX, salestax);
printf("Total %6.2lf\n", purchasettl);
if (customer == 'N') {
purchasettl = purchase * 1.05;
printf("\nTotal purchases $%.2f\n", purchase);
printf("Sales tax(%d%%) %.2f\n", NETTAX, salestax);
printf("Total %.2f", purchasettl);
}
system ("pause");
return (0);
}
|