I need help with this assignment,i typed up the code but i think i made a mistake or

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • randyx05
    New Member
    • Sep 2013
    • 3

    #1

    I need help with this assignment,i typed up the code but i think i made a mistake or

    Good Evening,

    I'm taking this introductory C++ class and i'm kinda confused with my code lol,I've pasted below both what is required and the code i have so far.Thanks

    "

    Prompt the user to enter a dog’s weight and number of days per month needing care,
    then calculate and display the daily rate and the total for the month (days times the daily
    rate)."

    Code:
    int main()
    {
    	int dogWeight,numOfDays;
    	cout << "Please enter the dog's weight" << endl;
    	cin >> dogWeight;
    	cout << "How many days per month does he need care? "<< endl;
    	cin >> numOfDays;
    	if (dogWeight <10 && numOfDays <10)
    		cout << "Your daily rate is " << 12 << " and your total for the month is " << 12*numOfDays << endl;
    	else
    		if (dogWeight <10 && numOfDays >10)
    			cout << "Your daily rate is " << 10 << " and your total for the month is " << 10*numOfDays << endl;
    		else
    			if (dogWeight =10<34 && numOfDays <10)
    				cout << "Your daily rate is " << 16 << " and your total for the month is " << 16*numOfDays << endl;
    			else
    				if (dogWeight =10<34 && numOfDays >10)
    					cout << "Your daily rate is " << 13 << " and your total for the month is " << 13*numOfDays << endl;
    				else
    					if (dogWeight >=35 && numOfDays <10)
    						cout << "Your daily rate is " << 19 << " and your total for the month is " << 19*numOfDays << endl;
    					else
    						if (dogWeight >=35 && numOfDays >10)
    							cout << "Your daily rate is " << 17 << " and your total for the month is " << 17*numOfDays << endl;
    	cout << "Press any key to continue ";
    	_getch();
    	return 0;
    Last edited by Rabbit; Sep 20 '13, 03:20 PM. Reason: Please use code tags when posting code or formatted data.
  • randyx05
    New Member
    • Sep 2013
    • 3

    #2
    Program runs but it displays same data for some of them such as if the dog weight is 35 and needs 11 days of care it will show $13 instead of the $17 i put it in above code.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Code:
      if ([B]dogWeight =10<34 [/B]&& numOfDays <10)
       cout << "Your daily rate is " << 16 << " and your total for the month is " << 16*numOfDays << endl;
       else
       if ([B]dogWeight =10<34 [/B]&& numOfDays >10)
       cout << "Your daily rate is " << 13 << " and your total for the month is " << 13*numOfDays << endl;
      This looks like a copy/paste error.

      I think you meant dogweight <=34

      Comment

      • randyx05
        New Member
        • Sep 2013
        • 3

        #4
        You're right,you can delete this sorry i should have double checked.

        Comment

        Working...