REC03_Problems

# REC03_Problems - 1 14:440:127 Introduction to Computers for Engineers Recitation 03 Problems Solutions Rutgers University Spring 2011 Instructor

This preview shows pages 1–2. Sign up to view the full content.

1 14:440:127– Introduction to Computers for Engineers Recitation 03 Problems Solutions Rutgers University, Spring 2011 Instructor - Brenda V. Cortez 1. Write a program with a function main that calls a function named myOperation , which prompts the user to enter two values ( x and y ) of type float and prints the result of calculating x y . Hint: main function is simply calling the function but nothing is returned to it. 2. Write a program with a function main that calls a function named myOperation , which prompts the user to enter two values ( x and y ) of type float , checks that they are positive using a while-loop , and then prints the result of calculating x y . Hint: main function is simply calling the function but nothing is returned to it. 3. Trim down your code for Problem 2 , by creating an additional function called checkIfPositive , that takes one argument and checks if is is positive. checkIfPositive should validate the argument’s value and return the validated value to where it was called from, so that x y can be calculated. Hint: Your function checkIfPositive will need to be called from myOperation since this is the function that prompts the user for input. NOTE : pow(x,y) doesn’t work with variables of type int 4. Write a program using the <string> class that prints the following menu to the user: Destinations: 1. Hawaii 2. Australia 3. France --------------------------- And prompts the user to enter the destination they wish to travel to and based on this prints the cost of a round trip airplane ticket out of Newark International Airport. If the user enters “Hawaii” or “hawaii”, the price is \$596. If the user enters “Australia” or “australia”, the price is \$1067, but if the user enters “France” or “france”, then the price is \$635. Anything else should make the program tell the user: “Your destination price is not available”. 5. Write a program with a

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/20/2011 for the course ENGR 127 taught by Professor Hunter,eleswarapu,cortez during the Spring '11 term at Rutgers.

### Page1 / 3

REC03_Problems - 1 14:440:127 Introduction to Computers for Engineers Recitation 03 Problems Solutions Rutgers University Spring 2011 Instructor

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online