Find Jobs
Hire Freelancers

CS 101 homework help

$-1-4 USD

Closed
Posted about 16 years ago

$-1-4 USD

Paid on delivery
Need help with basic cpp. I need an explanation of this code: ================================================ switch ( menuOption) { case 1: planetWeight = earthWeight * 0.39; // Mercury break; case 2: planetWeight = earthWeight * 0.91; // Venus break; case 3: planetWeight = earthWeight * 0.38; // Mars break; default: planetWeight = earthWeight - 1; // Earthweight - 1 // People like to think they're losing weight (marketing) break; } cout << " Your new weight is " << planetWeight "\n"; // Now illustrating the continue statement int firstNumber, secondNumber; for ( ; ; ) { // Begin infinite loop cout<< "Enter two integers, where we will divide the first by the second: "; cin>> firstNumber >> secondNumber; if ( secondNumber == 0 ) { continue; // Try again, as division by 0 is problematic } cout<< firstNumber << " / " << secondNumber << " = " << firstNumber/secondNumber << "\n; } cout<< "You will never see this secret message. My locker combination is: 22-46-19."; return 0; } ===================================================== 1) firstNumber and secondNumber are ints: will the result be an int or a decimal? 2)how can I make sure it shows as decimal? 3) if I erase the break; 's from the switch, the program gives output, but doesn't work right. If I erase all the breaks will it perform the last case or the default? 4) Why does for(;;) actully loop? Is it possible to do empty loops with while too? Why use empty loops?
Project ID: 3921433

About the project

14 proposals
Remote project
Active 16 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
14 freelancers are bidding on average $3 USD for this job
User Avatar
See private message.
$3.40 USD in 1 day
4.9 (108 reviews)
5.0
5.0
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (69 reviews)
4.6
4.6
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (57 reviews)
4.3
4.3
User Avatar
See private message.
$3.40 USD in 1 day
4.5 (35 reviews)
4.4
4.4
User Avatar
See private message.
$3.40 USD in 1 day
4.8 (13 reviews)
4.0
4.0
User Avatar
See private message.
$3.40 USD in 1 day
4.3 (17 reviews)
3.8
3.8
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (8 reviews)
2.8
2.8
User Avatar
See private message.
$3.40 USD in 1 day
4.9 (7 reviews)
2.3
2.3
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (3 reviews)
2.2
2.2
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (3 reviews)
1.9
1.9
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (2 reviews)
1.3
1.3
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (2 reviews)
1.2
1.2
User Avatar
See private message.
$3.40 USD in 1 day
5.0 (1 review)
0.0
0.0
User Avatar
See private message.
$3.40 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
0.0
0
Member since May 9, 2008

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.