Results 1 to 5 of 5

Thread: plz help me in the following c++ program

  1. #1
    raza89's Avatar
    raza89 is offline Junior Member
    Last Online
    5th November 2009 @ 03:29 PM
    Join Date
    14 Feb 2009
    Location
    Rawalpindi
    Posts
    27
    Threads
    13
    Credits
    0
    Thanked
    0

    Default plz help me in the following c++ program

    You are required to write a program for Movie Rental Store. The basic idea is that user/reader will provide customer information, movie name, and number of days. Upon this information your program will calculate the charged amount for that movie.




    Detailed Description:

    1. The program should display

    Please provide customer Name:
    Please provide Movie Description.
    Enter ‘R’ for Regular Movie.
    Enter ‘C’ for children Movie.
    Enter ‘N’ for New Released Movie.
    Enter ‘E’ for English Movie.

    Then your program should take these inputs,

    2. Depending upon the choices that user has entered, your program will further display the prompt

    3. If user has entered Movie description, then your program should prompt the user to enter the Movie Name and Number of days.

    -----------------------------------------------------------------
    Movie Name :
    Number of day’s:
    -----------------------------------------------------------------

    4. After getting all this information, now write a function which will calculate rental/charged amount on the basis of this information.


    To calculate rental/charged amount we will use this formula:
    Rental amount = charged amount * number of days

    Charged amount will be different for different movies according to following description:

    Regular Movie: 40 RS
    Children Movie: 30 RS
    English Movie: 50 RS
    New release: 100 RS


    After calculating charged amount for this movie and display it on the screen.




    Sample Output



    Please provide customer Name: Aftab

    Please provide Movie Description:
    Enter ‘R’ for Regular Movie:
    Enter ‘C’ for children Movie:
    Enter ‘N’ for New Released Movie:
    Enter ‘E’ for English Movie:

    R

    Please provide following information:
    Movie Name : Jinnah
    Number of day’s: 3


    Final output:

    -----------------------------------------------------------------
    Customer Name: Aftab
    Movie Type : Regular
    Movie Name : Jinah
    Number of day’s: 3
    Your Rental Amount is: 120 Rs

  2. #2
    SufyanGujar is offline Senior Member+
    Last Online
    29th December 2010 @ 10:59 PM
    Join Date
    10 Oct 2009
    Location
    England, UK
    Age
    34
    Posts
    157
    Threads
    10
    Credits
    0
    Thanked
    7

    Default

    Here u go bro,

    Code:
    string name;
    string type;
    string movie;
    int days;
    int cost;
    int rentalamount;
    
    cout << "Please Provide Customer Name:\n";
    cin >> name;
    cout << "Please Provide Movie Description:\n\n";
    cout << "Enter 'R' for Regular Movie\n";
    cout << "Enter 'C' for Children Movie\n";
    cout << "Enter 'N' for New Released Movie\n";
    cout << "Enter 'E' for English Movie\n";
    cin >> type;
    
    if (type == "E" ||"e")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 50;
    }
            
    else if (type == "N" || "n")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 100;
    }
        
    else if (type == "C" || "c")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 30;
    }
    
    else if (type == "R" || "r")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 40;     
    }
    
    rentalamount = rental(cost, days);
    
    cout << "Total Rental = " << rentalamount << "RS" << endl;
    
    system ("PAUSE");
    
    }
    
    int rental(int cost, int days)
    {
        int total;
        total = cost * days;
        return total;
    }
    yeh almost same hai, agar kuch reh gya ho to, i hope you can add it.
    but i think thats it.
    Thnx

  3. #3
    SufyanGujar is offline Senior Member+
    Last Online
    29th December 2010 @ 10:59 PM
    Join Date
    10 Oct 2009
    Location
    England, UK
    Age
    34
    Posts
    157
    Threads
    10
    Credits
    0
    Thanked
    7

    Default

    sory some code missing in that,
    is ko try karo:

    Code:
    #include <iostream>
    #include <String>
    
    using namespace std;
    
    int rental(int,int);
    
    main()
    {
        
    string name;
    string type;
    string movie;
    int days;
    int cost;
    int rentalamount;
    
    cout << "Please Provide Customer Name:\n";
    cin >> name;
    cout << "Please Provide Movie Description:\n\n";
    cout << "Enter 'R' for Regular Movie\n";
    cout << "Enter 'C' for Children Movie\n";
    cout << "Enter 'N' for New Released Movie\n";
    cout << "Enter 'E' for English Movie\n";
    cin >> type;
    
    if (type == "E" ||"e")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 50;
    }
            
    else if (type == "N" || "n")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 100;
    }
        
    else if (type == "C" || "c")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 30;
    }
    
    else if (type == "R" || "r")
    {
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    cost = 40;     
    }
    
    rentalamount = rental(cost, days);
    
    cout << "Total Rental = " << rentalamount << "RS" << endl;
    
    system ("PAUSE");
    
    }
    
    int rental(int cost, int days)
    {
        int total;
        total = cost * days;
        return total;
    }
    Thnx

  4. #4
    SufyanGujar is offline Senior Member+
    Last Online
    29th December 2010 @ 10:59 PM
    Join Date
    10 Oct 2009
    Location
    England, UK
    Age
    34
    Posts
    157
    Threads
    10
    Credits
    0
    Thanked
    7

    Default

    Now it might be a bit anoying but i waz looking at Sample code and found out that the code posted above give wrong calculations, so i edited code and here it is:

    Screenshot:



    Code:
    #include <iostream>
    #include <String>
    
    using namespace std;
    
    int rental(int,int);
    
    main()
    {
        
    string name, movie;
    char type;
    int days, cost, rentalamount;
    
    cout << "Please Provide Customer Name:\n";
    cin >> name;
    cout << "Please Provide Movie Description:\n\n";
    cout << "Enter 'R' for Regular Movie\n";
    cout << "Enter 'C' for Children Movie\n";
    cout << "Enter 'N' for New Released Movie\n";
    cout << "Enter 'E' for English Movie\n";
    cin >> type;
    
    cout << "Movie Name:\n";
    cin >> movie;
    cout << "Number of day's:\n";
    cin >> days;
    
    
    switch (type)
    {
           case 'R': cost = 40;
           break;
           case 'E': cost = 50;
           break;
           case 'N': cost = 100;
           break;
           case 'C': cost = 30;
           break;
           
           default: cout << "Bad Selection\n";
                    cost = 0;
    }
           
    
    rentalamount = rental(cost, days);
    
    cout << "Total Rental = " << rentalamount << "RS" << endl;
    
    system ("PAUSE");
    
    return 0;
    
    }
    
    int rental(int cost, int days)
    {
        int total;
        total = cost * days;
        return total;
    }
    Off Topic:

    Total Cost: $200 only
    but for u i will only cost $ 100
    so yea send me $100 on my paypal,
    email is: xxx@xxx.xxx.
    [ hehe]
    Thnx

  5. #5
    raza89's Avatar
    raza89 is offline Junior Member
    Last Online
    5th November 2009 @ 03:29 PM
    Join Date
    14 Feb 2009
    Location
    Rawalpindi
    Posts
    27
    Threads
    13
    Credits
    0
    Thanked
    0

    Default

    Dear.
    thanxs to all

Similar Threads

  1. sab program
    By k_mbhutta in forum Ask an Expert
    Replies: 1
    Last Post: 5th July 2011, 08:47 PM
  2. c program
    By SHUMAILA AHMED in forum Ask an Expert
    Replies: 0
    Last Post: 2nd May 2011, 05:35 PM
  3. program
    By irfankhanl in forum Ask an Expert
    Replies: 1
    Last Post: 3rd August 2010, 08:42 PM
  4. program plz 2
    By PREMkhan in forum Ask an Expert
    Replies: 2
    Last Post: 26th May 2010, 12:30 AM
  5. program plz 4
    By PREMkhan in forum Ask an Expert
    Replies: 1
    Last Post: 25th May 2010, 11:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •