RE: Here is my modified program, thoughts? corrections?

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 15 Jul 2010 12:53:00 -0700

Hi Ian,

That's a very good observation - I should have gone over that yesterday,
sorry. Yes, the >= and <= would have catched all values.

The conditional statements would go inside the while loop, and it needs to
increment both the total price and the number of registrants. This would be
faster if we use arrays, but Jess has not learned it yet, thus our "while
loop" issue.

Cheers,

Joseph

 

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Ian D. Nichols
Sent: Thursday, July 15, 2010 12:25 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Here is my modified program, thoughts? corrections?

 

Hi everyone,

 

There is a problem with Jes's logic here.  He wrote if (regNumber > 1 &&
regNumber < 3).

 

But 1 is not greater than 1, and 3 is not less than 3, so the only number
that will be recognized here will be 2.

 

The if statement about 4 and 9 has the same problem.

 

What is meant, I feel sure, is 

 

if (regNumber >= 1 && regNumber <= 3)

 

That will pick up 1, 2 or 3.  Similar operators in the 4 and 9 statement
will recognize all numbers from 4 to 9 inclusive.

 

I also think that there are difficulties with what is included in the while
loop and what isn't, but haven't looked closely at that yet.

 

HTH.

 

Ian

 

Ian D. Nichols,

Toronto, Canada

 

 

----- Original Message ----- 

From: Jes <mailto:theeternalkid@xxxxxxxxx>  

To: programmingblind@xxxxxxxxxxxxx 

Sent: Thursday, July 15, 2010 3:00 PM

Subject: Re: Here is my modified program, thoughts? corrections?

 

Hi Jim, 

The statement which talks about 4 and 9 tells the program, if there are
between 4 and 9 registrants, the fee is 100 dollars.

The whole thing goes like this:

If a company enters  at least 1, up to 3 registrants, the fee is 150
dollars. If they enter 4 to 9 registrants, the fee is 100 dollars, and if it
is ten or more people, it's 90 dollars.

So, if I understand this correctly, Jim, if the first company entered 8
people and the second company entered 10, the total fee would be 

190 dollars. 100 dollars for the first 8 people, and then 90 dollars for the
other ten.

Jes

 

On Jul 15, 2010, at 11:59 AM, Homme, James wrote:





Hi,

I can't figure this out. Maybe you need to have && in the statement that
talks about > 4 & < 9. But what's going on if it is either 4 or 9?

Jim

Jim Homme,

Usability Services,

Phone: 412-544-1810. Skype: jim.homme

Internal recipients,  Read my
<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>
accessibility blog. Discuss
<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>
accessibility here.Accessibility
<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%2
0Wiki/Forms/AllPages.aspx>  Wiki: Breaking news and accessibility advice

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
Sent: Thursday, July 15, 2010 11:32 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Here is my modified program, thoughts? corrections?

***program:

//Ch7AppE04.cpp

 //Displays total price of registrations.

//Created/revised by <Jes Smith on July 15, 2010.

#include <iostream>

#include <iomanip>

using std::cout;

using std::cin;

using std::endl;

//using std::fixed;

//using std::setprecision;

//declare variables

float totalPrice = 0;

float averagePayment = 0; 

int regNumber = 0;

//regNumber, The number of registrants stored in this variable.

//totalPrice The total cost for the company.

//averagePayment The payment the registrant makes to the company for
attending the seminar.

int main()

{

cout << "Enter number of people who will be registered. \n Press enter after
each number.\n Enter a negative number to get the total price: " << endl;

cin >> regNumber;

 while (regNumber >= 0)

{

cout << "Enter your next entry. Enter negative number to get total price: "
<<endl;

cin >> regNumber;

} //endwhile

if (regNumber > 1 && regNumber < 3)

totalPrice = 150;

else if (regNumber > 4 < 9);

totalPrice = 100;

 if (regNumber >= 10)

 {

                totalPrice = 90;}

totalPrice = (regNumber + totalPrice);

cout << regNumber << endl;

cout << totalPrice << endl;

return 0;

} //end of main function

 


  _____  


This e-mail and any attachments to it are confidential and are intended
solely for use of the individual or entity to whom they are addressed. If
you have received this e-mail in error, please notify the sender immediately
and then delete it. If you are not the intended recipient, you must not
keep, use, disclose, copy or distribute this e-mail without the author's
prior permission. The views expressed in this e-mail message do not
necessarily represent the views of Highmark Inc., its subsidiaries, or
affiliates.

 

No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.441 / Virus Database: 271.1.1/3007 - Release Date: 07/15/10
11:09:00

Other related posts: