View Single Post
Old 21-09-2007, 08:43 AM   #187 (permalink)
Glen Apayart
Right Off the Assembly Line
 
Glen Apayart's Avatar
 
Join Date: Sep 2007
Location: Philippines
Posts: 5
Default Re: Post ur C/C++ Programs Here

This is my first program in c++.

Actually its working well and i just want to know the comments or suggestion about my program. i know it still need more code to make it stable and effective.

Program: a simple shop using string, integers, float, & algebraic operators
Code:
#include <iostream>
using namespace std;

int main()
{
    char firstName[20], lastName[20];

    unsigned short shirts;
    unsigned short pants;
    unsigned short shoes;
    unsigned short caps;
    unsigned short totalItems;

    double priceShirts = 1.25;
    double pricePants = 2.75;
    double priceShoes = 3.25;
    double priceCaps = 1.65;

    float totalShirts;
    float totalPants;
    float totalShoes;
    float totalCaps;
    float all, payment, change;

    int orderDay;
    int orderMonth;
    int orderYear;

    cout << "-=- Apayart Botique -=-";
    cout << "\nEnter your personal information";
    cout << "\nFirst Name: ";
    cin >> ws;
    cin.getline(firstName, 20);
    cout << "Last Name: ";
    cin >> ws;
    cin.getline(lastName, 20);

    cout << "\nEnter date of order";
    cout << "\nOrder Day: ";
    cin >> orderDay;
    cout << "Order Month: ";
    cin >> orderMonth;
    cout << "Order Year: ";
    cin >> orderYear;

    cout << "\nEnter number of shirts: ";
    cin >> shirts;
    cout << "Enter number of pants: ";
    cin >> pants;
    cout << "Enter number of shoes: ";
    cin >> shoes;
    cout << "Enter number of caps: ";
    cin >> caps;

    totalShirts = shirts * priceShirts;
    totalPants = pants * pricePants;
    totalShoes = shoes * priceShoes;
    totalCaps = caps * priceCaps;
    totalItems = shirts + pants + shoes + caps;
    all = totalShirts + totalPants + totalShoes + totalCaps; 

    cout << "\ntotal price: $"; << all;
    cout <<"\nYour payments: $";
    cin >> payment;

    change = payment - all;

    cout << "\n=======================";
    cout << "\n-=- Apayart Botique -=-";
    cout << "\n=======================";
    cout << "\nCustomer Order";
    cout << "\n\tCustomer Name: " << firstName << " " << lastName;
    cout << "\n\tOrder Date: ";
    cout << orderMonth << "/" << orderDay << "/" << orderYear;
    cout << "\n------------------------------";
    cout << "\nItems type    Qty     Price";
    cout << "\n------------------------------";
    cout << "\nShirts        " << shirts << "     $" << totalShirts;
    cout << "\nPants        " << pants << "     $" << totalPants;
    cout << "\nShoes        " << shoes << "     $" << totalShoes;
    cout << "\nCaps        " << caps << "     $ "<< totalCaps;
    cout << "\n------------------------------;
    cout << "\nTotal Items: "; << totalItems;
    cout << "\n\nTotal Price: $" << all;
    cout << "\nPayment: $" << payment;
    cout << "\nChange: $" << change << "\n\n\n\n\n\n";

    return 0;

}
__________________
Deitel: http://wps.prenhall.com/esm_deitel_chtp_4/
FunctionX: http://www.functionx.com/index.htm

Last edited by Glen Apayart; 21-09-2007 at 03:08 PM.
Glen Apayart is offline