I need help w/ this, just beginning and im lost

Write a program that allows a user to enter two integer values. Display every whole number that falls between these values.

2. Write a program for a furniture company. Ask the user to choose P for pine, O for oak or M for mahogany. Show the price of a table manufactured with the chosen wood. Prices for pine tables are $100, oak tables are $225 and mahogany tables are $350.

Comments

  • Not sure if you still need this. Here's problem 1.

    [code]
    #include

    using namespace std;

    int main ()
    {
    cout << "Enter two values" << endl;
    int a,b;
    cin >> a >> b;

    cout << "



    ";
    while(a<b){
    cout << a << ", "; //prints number; comma for formatting
    a++; /*raises the value of "a" until it is one less than b, ending the
    loop.*/
    }
    cout << b; /* The while loop iterated until one less than b. We still
    wish to print b. Prints only number with no comma after it*/

    int z;
    cin >> z;
    return 0;

    }

  • Not sure if you still need this. Here's problem 1.

    [code]
    #include

    using namespace std;

    int main ()
    {
    cout << "Enter two values" << endl;
    int a,b;
    cin >> a >> b;

    cout << "



    ";
    while(a<b){
    cout << a << ", "; //prints number; comma for formatting
    a++; /*raises the value of "a" until it is one less than b, ending the
    loop.*/
    }
    cout << b; /* The while loop iterated until one less than b. We still
    wish to print b. Prints only number with no comma after it*/

    int z;
    cin >> z;
    return 0;

    }

  • # include

    int main ()

    {

    int a,b,c;

    cout << "enter you values"<<endl;
    cin <<a<<b;

    Do
    {
    a= a+1
    count <<a<<endl;
    a= a+1

    }
    (while a!=b)


    return 0;
    }


    //this will display all the unit_values between a and b.
  • # include

    int main ()

    {

    int a,b,c;

    cout << "enter you values"<<endl;
    cin <<a<<b;

    Do
    {
    a= a+1
    count <<a<<endl;
    a= a+1

    }
    (while a!=b)


    return 0;
    }


    //this will display all the unit_values between a and b.
  • ***disregard my last post. This code will work correctly in both cases ab [and if a=b it it goes into an infinate loop]***

    include


    int main()
    {
    int a,b;

    cout<< "Enter your values."<<endl;
    cin>>a>>b;


    if (a<b)
    do
    {
    a=a+1;
    cout <<a<< endl;
    }
    while(a!=b);

    else

    do
    {
    a=a-1;
    cout <<a<< endl;
    }
    while(a!=b);

    return 0;
    }

  • ***Also, I'm trying this approach as a resolve for your question. But I thik its a more appropriate approach to be used for this question***

    #include

    using namespace std;

    int main()
    {
    int a,b,c;
    double r;
    char ch,o,m,p;

    c=0;

    cout<< "Enter your spending limit."<<endl;
    cin>>b;
    cout<< "Please choose between Pine, Oak, Mahoganhi."<<endl;
    cin>>ch;

    switch(ch)
    {



    case 'p':

    a = 100;
    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;

    case 'o':
    a=225;

    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;

    case 'm':

    a=350;
    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;
    }


    return 0;
    }
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories