The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.
Declare a const named CENTS_PER_POUND and initialize with 25.
Get the shipping weight from user input storing the weight into shipWeightPounds.
Using FLAT_FEE_CENTS and CENTS_PER_POUND constants, assign shipCostCents with the cost of shipping a package weighing shipWeightPounds.
#include
using namespace std;
int main() {
int shipWeightPounds;
int shipCostCents = 0;
const int FLAT_FEE_CENTS = 75;
/* Your solution goes here */
cout << "Weight(lb): " << shipWeightPounds;
cout << ", Flat fee(cents): " << FLAT_FEE_CENTS;
cout << ", Cents per lb: " << CENTS_PER_POUND << endl;
cout << "Shipping cost(cents): " << shipCostCents << endl;
return 0;
}
Using the code stub below, compute the acceleration of gravity for a given distance from the earth's center, distCenter, assigning the result to accelGravity. The expression for the acceleration of gravity is: (G * M) / (d2), where G is the gravitational constant 6.673 x 10-11, M is the mass of the earth 5.98 x 1024 (in kg) and d is the distance in meters from the earth's center (stored in variable distCenter).
#include
using namespace std;
int main() {
double G = 6.673e-11;
double M = 5.98e24;
double accelGravity;
double distCenter;
cin >> distCenter;
/* Your solution goes here */
cout << accelGravity << endl;
return 0;
}
Given sphereRadius, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division. Volume of sphere = (4.0 / 3.0) π r3 (Hint: r3 can be computed using *)
#include
#include
#include
using namespace std;
int main() {
double sphereVolume;
double sphereRadius;
cin >> sphereRadius;
/* Your solution goes here */
cout << fixed << setprecision(2) << sphereVolume << endl;
return 0;
}
A drink costs 2 dollars. A taco costs 4 dollars. Given the number of each, compute total cost and assign totalCost with the result. Ex: 4 drinks and 6 tacos yields totalCost of 32.
#include <iostream>
using namespace std;
int main() {
int numDrinks;
int numTacos;
int totalCost;
cin >> numDrinks;
cin >> numTacos;
/* Your solution goes here */
cout << "Total cost: " << totalCost << endl;
return 0;
}
Q1.You are required to write a computer program that accepts a decimal number and generates a corresponding binary, octal, and hexadecimal output.
Q2. Write a program that accepts binary input string and generates corresponding octal and hexadecimal outputs respectively.
Use dynamic list to declare array of 10 integers, then write the following function:
(show the output for each function)
1- Insert an integer at the beginning of the array
2- Delete the last element of the array
Using the code stub below, write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1 is 4 and num2 is 5, finalResult is 3.
#include <iostream>
using namespace std;
int main() {
int num1;
int num2;
int finalResult;
cin >> num1;
cin >> num2;
/* Your solution goes here */
cout << "Final result: " << finalResult << endl;
return 0;
}
Q1.You are required to write a computer program that accepts a decimal number and generates a corresponding binary, octal, and hexadecimal output.
Q2. Write a program that accepts binary input string and generates corresponding octal and hexadecimal outputs respectively.