473,378 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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)."

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     int dogWeight,numOfDays;
  4.     cout << "Please enter the dog's weight" << endl;
  5.     cin >> dogWeight;
  6.     cout << "How many days per month does he need care? "<< endl;
  7.     cin >> numOfDays;
  8.     if (dogWeight <10 && numOfDays <10)
  9.         cout << "Your daily rate is " << 12 << " and your total for the month is " << 12*numOfDays << endl;
  10.     else
  11.         if (dogWeight <10 && numOfDays >10)
  12.             cout << "Your daily rate is " << 10 << " and your total for the month is " << 10*numOfDays << endl;
  13.         else
  14.             if (dogWeight =10<34 && numOfDays <10)
  15.                 cout << "Your daily rate is " << 16 << " and your total for the month is " << 16*numOfDays << endl;
  16.             else
  17.                 if (dogWeight =10<34 && numOfDays >10)
  18.                     cout << "Your daily rate is " << 13 << " and your total for the month is " << 13*numOfDays << endl;
  19.                 else
  20.                     if (dogWeight >=35 && numOfDays <10)
  21.                         cout << "Your daily rate is " << 19 << " and your total for the month is " << 19*numOfDays << endl;
  22.                     else
  23.                         if (dogWeight >=35 && numOfDays >10)
  24.                             cout << "Your daily rate is " << 17 << " and your total for the month is " << 17*numOfDays << endl;
  25.     cout << "Press any key to continue ";
  26.     _getch();
  27.     return 0;
Sep 20 '13 #1

✓ answered by weaknessforcats

Expand|Select|Wrap|Line Numbers
  1. if (dogWeight =10<34 && numOfDays <10)
  2.  cout << "Your daily rate is " << 16 << " and your total for the month is " << 16*numOfDays << endl;
  3.  else
  4.  if (dogWeight =10<34 && numOfDays >10)
  5.  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

3 2229
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.
Sep 20 '13 #2
weaknessforcats
9,208 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. if (dogWeight =10<34 && numOfDays <10)
  2.  cout << "Your daily rate is " << 16 << " and your total for the month is " << 16*numOfDays << endl;
  3.  else
  4.  if (dogWeight =10<34 && numOfDays >10)
  5.  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
Sep 20 '13 #3
You're right,you can delete this sorry i should have double checked.
Sep 20 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MT | last post by:
I have an xsd file that I use to create a strongly typed dataset in my project. In the past, I have used the ReadXml method to load xml files into the generated class and read data in using this...
3
by: Paul T. Rong | last post by:
Dear all, My aim is to compact and repair current database, I got the following code from http://www.mvps.org/access/general/gen0041.htm Option Compare Database ' ***** Code Start *****...
1
by: Matthew Wilson | last post by:
I need to write a function crc(msg, len) that gets a char array of length len and then calculates the crc32 for the code. I don't understand what's going wrong in the code I have. It goes...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
1
by: priya | last post by:
hi.i made mistake while copying my code sorry friends.This is the one i tried .i got o/p for dynamic rows how should i h'v to incorporate "onChange"event in "setAttribute". following code is not...
22
by: walter.preuninger | last post by:
Is there an easier way to code the cmp procedure without going thru all the pointer manipulations? #include <stdlib.h> #include <string.h> int cmp(const void *i, const void *j) { void *p1,...
0
by: Allen Maki | last post by:
I would be pleased if someone gives me a general idea; how I am going to do this. I am using visual C++ .NET 2003. I made a simple program using conventional C++ code. This program accepts...
5
by: Weihui Shen | last post by:
Hello. Sometimes I see that some class constructors were implemented with assignment operator and I wanna know whether it is safe to do that or not?
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.