C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 15th, 2013, 01:45 PM
Mefear Mefear is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 Mefear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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);
       }
       
       
       
    
    
    

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Problem help


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap