PCinvent.info

PCinvent Studio Template

Aug 16 2008
C++ Homework: Movie Ticket Donation Print E-mail
Saturday, 16 August 2008


Read More Articles in: Technology>>>Programming

This Article is written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it


Time to post my C++ homework I did. This one is a very basic Calculation on the Donation and movie ticket Sale......

 

//File Name:    movieTicket.cpp
//Description:   Calculate the Donation and movie ticket Sale
//Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main()
{
    //Declaration
    string movieName;
    double adultTicketPrice=0, childTicketPrice=0;
    int noOfAdultTicketsSold=0, noOfChildTicketsSold=0;
    double percentDonation=0, grossAmount=0, amountDonated=0, netSaleAmount=0;

    cout<<fixed<<showpoint<<setprecision(2);
/////////////////////////////////////////////////////////////////////////
    cout<<"Please enter the Movie Name"<<endl;
    getline(cin,movieName);

    cout<<"Please enter the Number of Adult Tickets Sold"<<endl;
    cin>>noOfAdultTicketsSold;
    cout<<"Adult Tickets Price?"<<endl;
    cin>>adultTicketPrice;

    cout<<"Please enter the Number of Child Tickets Sold"<<endl;
    cin>>noOfChildTicketsSold;
    cout<<"Child Tickets Price?"<<endl;
    cin>>childTicketPrice;

    cout<<"Please enter the Percentage of Donation (%)"<<endl;
    cin>>percentDonation;

/////////////////////////////////////////////////////////////////////////
    //Result Output
    cout<<"_*_*_*_*_*_*_*_*_*_*_*_*"
        <<"_*_*_*_*_*_*_*_*_*_*_*_*"<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Movie Name: "
        <<right<<" "<<movieName<<endl;
    cout<<setfill('.')<<left<<setw(35)<<"Number of Tickets Sold: "
        <<setfill(' ')<<right<<setw(10)
        <<noOfAdultTicketsSold + noOfChildTicketsSold
        <<endl;

    //gross amount
    cout<<setfill('.')<<left<<setw(35)
        <<"Gross Amount: "
        <<setfill(' ')<<right<<" $";
    grossAmount = (noOfAdultTicketsSold * adultTicketPrice)+ (noOfChildTicketsSold * childTicketPrice);
    cout<<setw(8)<<grossAmount<<endl;

    //percent donation
    cout<<setfill('.')<<left<<setw(35)
        <<"Percent Donation: "
        <<setfill(' ')<<right<<" $";
    cout<<setw(8)<<percentDonation<<"%"<<endl;

    //Amount of donation
    cout<<setfill('.')<<left<<setw(35)
        <<"Amount  Donation: "
        <<setfill(' ')<<right<<" $";
    amountDonated = (percentDonation * grossAmount) /100;
    cout<<setw(8)<<amountDonated<<endl;

        //Net Sale Amount
        cout<<setfill('.')<<left<<setw(35)
                <<"Net Sale Amount: "
                <<setfill(' ')<<right<<" $";
        netSaleAmount = grossAmount - amountDonated;
        cout<<setw(8)<<netSaleAmount<<endl;


////////////////////////////////////////////////////////////////////////   
    return 0;

}//end of int main()

Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

busy
Tags:  Technology Programming C++ Homework Movie Ticket Donation
Last Updated ( Saturday, 16 August 2008 )
 
< Prev   Next >
Site by PCinvent.com