Concept explainers
The following is a short
#include <iostream>
using namespace std;
int main()
{
double radius, vm;
cout << “Enter radius of a sphere.” << endl; cin >> radius;
vm = (4.0 / 3.0) * 3.1415 * radius * radius * radius;
cout << “ The volume is “ << vm << endl;
return 0;
}
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: Early Objects (6th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Web Development and Design Foundations with HTML5 (8th Edition)
Software Engineering (10th Edition)
Modern Database Management
Starting Out with C++ from Control Structures to Objects (8th Edition)
- I am needing assistance with the following program build in C++. To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters. Also output the – (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.arrow_forwardA "jiffy" is the scientific name for 1/100th of a second. Define a function named jiffies_to_seconds that takes the number of "jiffies" as a parameter, and returns the number of seconds. Then, write a main program that reads the number of jiffies (float) as an input, calls function jiffies_to_seconds() with the input as argument, and outputs the number of seconds. Output each floating-point value with three digits after the decimal point, which can be achieved as follows:print(f'{your_value:.3f}') Ex: If the input is: 15.25 the output is: 0.152 The program must define and call the following function: def jiffies_to_seconds(user_jiffies) MY CODE: def jiffies_to_seconds(user_seconds): jiffies = user_seconds*100 return jiffies #main of programif __name__ == '__main__': user_seconds = float(input()) jiffies = jiffies_to_seconds (user_seconds) print(f'{user_seconds:.3f}') ERROR: Not understanding the correct function here. The output is putting the decimal in the wrong…arrow_forwardPROBLEM: Write a program that prompts the user to input coefficients A, B, and C of a quadratic equation in general form (Ax^2 + Bx + C = 0) to determine the nature of the roots of the quadratic equation. SPECIFICATIONS: - You may only use the codes that we studied under our lectures - All lines of codes should have a comment. - Save your cpp file as Surname - PE (Example: Pangaliman - PE.cpp) TEST CASES: If a user inputs the three coefficients of a quadratic equation: Enter A: 1 Enter B: 7 Enter C: 12 Result: The roots are real and distinct. If a user inputs the three coefficients of a quadratic equation: Enter A: 2 Enter B: 2 Enter C: 3 Result: The roots are complex and distinct.arrow_forward
- The output of this code is __________. double incrementAndDouble(double& original) { original++; return original * 2; } int main() { double original = 5.0; double result = incrementAndDouble(original); std::cout << std::fixed << std::setprecision(1) << original << " " << result; } The following code won't compile. In one sentence, explain why the compiler doesn’t know what to do with the function call on line 10. (Hint, it will say that the function call is ambiguous.) double multiplyThem(double first, double second) { return first * second;} double multiplyThem(double first, double second, double third=1.0) { return first * second * third;} int main() { double result = multiplyThem(5.0, 6.0);}arrow_forwardIf you run the following program, in which order the statements of this program will be executed? Your answer should be a sequence of comma separated line numbers without any extra spaces, e.g., 1,2,3,4,5,6,7,8 etc.arrow_forwardIn C++ just do the problems in simple, not complicated code. Even if a problem does not directly tell you to use a function, you should aim to do so regardless. 1. Create a function that takes in a number n and outputs all the odd numbers from 1 to n. 2. Create a function that takes in a int number and outputs each of the digits backwards 3. Create a function that counts backwards from 100 to 1. 4. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000. Use a function to do this. Return the total to main.arrow_forward
- Answer properly(editable code , output screenshot) is must Write a C++ program to input electricity unit charges and calculate total electricity bill according to the given condition:For first 50 units Rs. 0.50/unitFor next 100 units Rs. 0.75/unitFor next 100 units Rs. 1.20/unitFor unit above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the billarrow_forwardWrite a program in C++ that should calculate the insurnace for a house. use questions below to write your programm. what is your first? what last name? how many people are living in the houes? how much did you bought the house for? how many bedrom does it have? what is the lenght in squre feet? - use Loop so everyone can repeat the programm. use function like "viod" and any other function. and finally use this formula: X/150*y/*50 x is the total price of the house y is the number of bedrooms s is the lenght in square feet.arrow_forwardI can't seem to figure this out.. for python You have a business that cleans floors in commercial space and offices. You charge customers $0.45 per square yard, and some customers require multiple cleanings every month. You need two custom functions for your business. The first function takes a floor's length and width in feet and returns the area in square yards. The second void function takes the area, charge per square yard, and number of monthly cleanings as arguments and prints the cleaning cost. This latter function uses selection logic to print different output for single and multiple monthly cleanings (see Sample Outputs). Use a properly named constant for the charge per square yard, too.arrow_forward
- In C++, please revise/fix the program below according to the instructions and all the criteria. I believe the problem is in int main(). Thank you. Instruction Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case. Write 2 versions of the function: string remDups(const string& original); void remDups(const string& original, string& nodups); Suppose the original string is “Myrtle has big feet” The function returns MYRTLE HASBIGF Test the functions thoroughly. Criteria compile, run, test the test program compiles, runs, and calls both versions of the function without crashingthe test program tests the functions thoroughly function parameters and returns one function has one constant string reference parameter and returns a stringone function has one constant string reference parameter, one string reference parameter and…arrow_forward5.19 In Python Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Your program must define and call the following driving_cost() function. Given input parameters driven_miles, miles_per_gallon, and dollars_per_gallon, the function returns the dollar cost to drive those miles. Ex: If the function is called with: 50 20.0 3.1599 the function returns: 7.89975 def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon) Your program should call the function three times to determine the gas cost for 10 miles, 50 miles, and 400 miles.arrow_forwardYou are creating an application which requires the user to input the precise height of their garage (in metres) to determine which trucks will fit. Input is accepted using the input() function. What is the most appropriate approach to writing the code for type conversion of the input value and why? a. No type conversion necessary, since the Python interpreter will determine the best type for the value implicitly. b. Convert to int, since fractional number input values are valid. c. Convert to float, since fractional number input values are valid. d. No type conversion necessary, since the input will already be the appropriate type for numbers. e. Convert to float, since only whole number input values are valid. f. Convert to int, since only whole number input values are valid.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning