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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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