Jump to content
Hash, Inc. - Animation:Master

C++ 2023 Week 8


robcat2075

Recommended Posts

  • Hash Fellow

Lesson 16 Comparing Floats

Turns out... floating point numbers are never quite what they seem.

Program idea: write a program to test if a float variable set to 1.1 will be evaluated as equal to, greater than or less than 1.1

When that is known, add tests to the program to see how little needs to be added (or subtracted) to the explicit value to make the evaluation with the variable come out differently from before.

Program idea:

A bit of code like this will show that a floating point variable set to 1.1 will evaluate as greater than a literal 1.1

float myVariable;
myVariable = 1.1;

if (myVariable > 1.1) {
cout>> "myVariable is greater than 1.1"<< endl;
}

Write a program to test how little the literal 1.1 needs to be increased by to change the above outcome.

Lesson 17 C++ Conditions

Conditions allow you combine multiple small decisions into one big decision.

Program idea: Think of a job that has several qualifying factors. For example, an astronaut has to be in certain height and weight ranges

Write a program that prompts the user to enter their values for the factors and then tells them if they get the job.

If they don't qualify, tell them which category(s) they missed on.

Extra credit if your program has a use for both && and ||

 

@Roger @Shelton @Rodney

 

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...