Need help with a C++ assignment

Discussion in 'C++' started by mo94015, Feb 6, 2010.

  1. mo94015

    mo94015 New Member

    Joined:
    Feb 6, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    ca
    need to change this from availcredit01.cpp to availseats01.cpp and make the necessary adjustments
    1)ask user to enter the room size
    2)get room size
    3)ask user to enter number of students
    4)get enrolled
    5)set avilseats to room size minus enrolled
    6)display the available sets
    7)halt and return to operating system
    i'm a newb so any help would be greatly appreciated
    #include <iostream> // systems-supplied hdrs
    #include <cstdio> // scanf and printf
    using namespace std; // avoid std::cin ...

    int main (void) // main returns an int
    {
    /* main local space */
    double balance; // input variables
    double creditLimit; //

    double availCredit; // output variable

    /* begin procedural code */
    cout << "Enter balance: "; // prompt user
    cin >> balance; // get data
    cout << "Enter credit limit: "; // prompt user
    cin >> creditLimit; // get data

    /* processs input */
    availCredit = creditLimit - balance; // expression

    /* display output */
    printf("\nAvailable Credit: %.2f\n\n", availCredit);

    /* halt and return to operating system */
    return(0); // pass int back to o/s
    }

    /*

    Enter balance: 500.00 <- Soft-copy Output
    Enter credit limit: 3500.00

    Available credit: 3000.00 <- Note rounded result

    */
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck? We won't do your assignment for you, but don't mind giving some hints. Also please use code tags when posting code - and as you haven't, this suggests you haven't read the posting guidelines, so please go and read them before posting further.

    What variables do you think you might need? For example in 1 there is a mention of room size; does that imply anything for local storage? What about the other six requirements?

    Tackle each requirement one at a time. Do you know how to do 1? If not, can you think how you might modify
    Code:
    cout << "Enter balance: "; // prompt user
    
    to have the desired effect?

    Then onto step 2. Can you see how to do that? If not, do you think you might be able to modify
    Code:
    cin >> balance; // get data
    
    to do what is needed?
     
  3. mo94015

    mo94015 New Member

    Joined:
    Feb 6, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    ca
    would this be right?

    Code:
    #include<iostream>
    using namespace std;
    
    int main(void)
    {
    
       double roomSize = 0.0;
       double students = 0.0;
    
       cout << "please enter room size " << endl;
       cin >> roomSize;
       cout << " please enter number of students " << endl;
       cin << students;
    
       availseats = (roomSize - students);
    
       cout << "the number of availseats are: " << availseats << endl;
    
       system("pause");
       return 0;
    
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Does it work?

    Build it and if it builds, run it, and enter some data, and see if the displayed output is what you expected. If so, well done! If not, then no it isn't right and you'll need to start debugging it.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice