Write a float function that prompts the user for radius

Assignment Help C/C++ Programming
Reference no: EM13936891

1. Using the switch statement, write a program that will request an integer from the user in the range 1 - 5. It should then output a message in this form:

You entered the number one.
{or two, or whatever was entered}
If the user entered a number other than 1 - 5, the program should output a message to that effect. Note that you need to read the value as an int, not a char. Use the form cin >> x; where x is an int variable, not cin.get().

2. Rewrite the following code with a for loop:

int inputNum;
cin >> inputNum;
Value = inputNum;
while (Value <= 10) {
cout << Value;
++Value;
}

3. This is a two-part question.

a. Rewrite the code in the previous question using a do-while loop.

b. Under what circumstances will the do-while loop you wrote act differently than the while and for versions of this code?

4. A certain company sells three items.

Tacos: $1.67 each
Golf Bags: $158.99 each
Masking Tape Roll: $5 each
Write a program that asks the user to select one of the items from a menu (1 for tacos, 2 for golf bags, 3 for masking tape), then to enter a number to buy. The program computes the cost of the purchase, requests another item selection from the user, and so on. The user enters 0 from the item menu to quit. Once 0 has been entered, the program displays the total cost of goods purchased.

5. In a certain company, employees are paid extra for overtime using the following system. For every hour over 40 worked, the employee is paid 1.5 times hourly wages. For every hour over 50, the employee is paid 2 times hourly wages. For example, an employee who earns $10 an hour and works for 55 hours would receive:
Regular pay: 40 hrs x $10 = $400
Time-and-a-half: 10 hrs x 1.5 x $10 = $150
Double: 5 hrs x 2 x $10 = $100
Total: = $650
Write a program that prompts for the number of hours worked in a week and an hourly wage, and then calculates and displays the weekly pay.
The program should then ask the user if there is more data (have the user enter `y' for yes). If so, the process begins again with the prompt for hours worked.

6. Write a program that reads two floating-point values representing angles and displays a message stating which angle has the greater tangent value. Note that the trigonometric functions in the math library expect angles in radians, not degrees. 360 degrees = 2 x pi radians, so 45 degrees would be about 0.785 radians.

7. What is the output of the following program? Explain.
#include <iostream>
using namespace std;
void f(int i, int j) {
i = 5;
j = j + i;
cout << "f: i = " << i << endl;
cout << "f: j = " << j << endl;
}
int main () {
int i = 15;
int j = 30;
f(i, j);
cout << "main: i = " << i << endl;
cout << " main: j = " << j << endl;
}

8. Write a float function GetRadius() that prompts the user for a radius, extracts the user's response from cin, and then returns the response as its value. Note: in questions of this type, you should write a simple program to test your code. All you need in this case is a main function that calls your function with appropriate arguments.

9. Create an enumerated type with three values: POSITIVE, NEGATIVE, and ZERO. Write a function that prompts the user for an integer, reads the integer, and returns one of the enumerated values based on that number (e.g., returns NEGATIVE if the input number is < 0.). Write a main function that calls this function, and displays, using a switch statement, what category of number was entered. Example:
Please enter an integer: 6
The number you entered was positive.

10. This is a two-part question.

a. Write a function for the following formula.
Distance: computes the distance d traveled in t seconds by an object that started at rest and then accelerated at a meters per second per second.
d = at^2 /2

b. Briefly discuss your choice of parameters and their types.

Reference no: EM13936891

Questions Cloud

Prepare summary journal entries including disposition : Prepare summary journal entries for August, including the disposition of under- or over- allocated conversion costs. Assume no direct materials variances.
Explain the main principles involved in normalization : Does normalization also help you to collect differently spliced forms of a given gene by equalizing the relative abundance of those differently spliced mRNAs? And if it does why?
Nic saybin enterprises accounting department : Nic Saybin Enterprises Accounting Department collects all pertinent monthly operating data. Selected data are presented below for the current month. From the data provided,
Create a simple airline ticket reservation program in c++ : When the program is first started, it should read a data file called reservation.dat. If the file exists, the program must load its data for each record into the reservation linked list.
Write a float function that prompts the user for radius : Create an enumerated type with three values: POSITIVE, NEGATIVE, and ZERO. Write a function that prompts the user for an integer, reads the integer, and returns one of the enumerated values based on that number (e.g., returns NEGATIVE if the input..
Management document to provide a comprehensive idea : The above documents should clearly be developed using a project tool that is available to you. You should make necessary assumptions in deciding your basis that would yield to the above documents. You are required to state your assumptions clearly..
How does cloning impact both food safety and animal welfare : How does cloning impact both food safety and animal welfare, i.e., what is the relationship of cloning to both food safety and animal welfare?
What are the main ethical issues involved : What are the main ethical issues involved - what actions are available to Sharon to resolve the dilemma she faces?
List the steps in the cloning process : Researchers are unable to guarantee that their work with stem cells will produce beneficial results. How should this uncertainty influence the debate on whether scientists should be allowed to conduct such research? Why?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Design a special atm machine

design a special ATM machine to be used by needy people -  The association supplies the needy person with a pin number to be able to use the ATM machine.

  Write a program to illustrate how to use your class

Declare an array of 10 components of type bankAccount to process up to 10 customers and write a program to illustrate how to use your class.

  Derive class weekday from class datetime

We can retrieve any one of the date-time structure member using strftime - Derive class WeekDay from class DateTime such that WeekDay::display() will display local date time using values from the parameters and the corresponding weekday.

  Computes the sum and displays it

Prepare a C++ program that asks the user for an integer n and computes the sum 1^2+2^2+3^2+4^2+....+n^2 and displays it in the output screen.

  Class named realestate that has data members

Create a class named RealEstate that has data members to hold the price of a house, the number of bedrooms, and the number of baths. Member functions include overloaded insertion and extraction operations

  Complete the leadership in action case study

Complete the Leadership in Action case study for Lehman Brothers on page 276-277 in your textbook.

  Viewer features of the application

Sharon has started to use both the stock details management and the file information viewer features of the application. However, while using the file information viewer application, she accidentally enters the path of a folder that does not exist..

  Create a text adventure game that uses pointers

Create a text adventure game that uses pointers. You have a rich, eccentric Uncle Billy who is soon to be deceased.

  Why are timestamps used in the kerberos protocol

Assume that Alice shares a secret s with her company's server computer. When Alice is on a trip, she tries to store an important message in the CEO's account directory.

  Rewrite the code- buid the linked list without dummy node

Rewrite the code- buid the linked list without dummy node

  Strategies for successful health care marketing

Describe three different strategies for successful health care marketing and public relations.  Which is your personal favorite?  Why?

  Compare and contrast the mode operators ios

Compare and contrast the mode operators ios::in, ios::app, and ios::out. Provide a C++ code segment that illustrates the use of these mode operators.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd