Posts

Write a program that prompts the user to enter the min- utes (e.g., 1 billion), and displays the number of years and days for the minutes. For simplicity, assume a year has 365 days

Image
(Find the number of years) Write a program that prompts the user to enter the min- utes (e.g., 1 billion), and displays the number of years and days for the minutes. For  simplicity, assume a year has 365 days. #Beginner In gcc c++ compiler using namespace std; #include<iostream> using namespace std; int main() { int minutes; cout<< "enter the minutes : " ; cin>>minutes; const int year_per_minutes=365*24*60; const int day_per_minutes=24*60; int year=minutes/year_per_minutes; int day=(minutes%year_per_minutes)/(day_per_minutes); cout<< " " <<minutes<< " minutes is aproximately " <<year<< " years and " <<day<< " days" ; return 0; } copy Output enter the minutes : 1000000000  1000000000 minutes is aproximately 1902 years and 214 days [Program finished] Need of Programmer Need of Programmer ...

ShowCurrenttime gives a program that displays the current time in GMT. Revise the program so that it prompts the user to enter the time zone offset to GMT and displays the time in the specified time zone.

Image
(Current time) ShowCurrenttime gives a program that displays the  current time in GMT. Revise the program so that it prompts the user to enter the time  zone offset to GMT and displays the time in the specified time zone.  #Beginner #Intermediate In gcc c++ compiler using namespace std; #include<iostream> #include<ctime> using namespace std; int main() { int totalsec = time(0); int currentsec = totalsec % 60; int totalminutes= totalsec / 60; int currentminutes=totalminutes % 60; int totalhrs=totalminutes / 60; int currenthrs=totalhrs % 24; int gmt; cout<< "enter GMT zone -12 to +12 :" ; cin>>gmt; int currentgmthrs=(totalhrs+gmt)%24; cout<< "main time  " <<currenthrs<< " :" <<currentminutes<< " :" <<currentsec<< " GMT +0" <<endl; cout<< "your time " <<currentgmthrs<< " :" <<currentm...

Average acceleration is defined as the change of velocity divided by the time taken to make the change, as shown in the following formula:

(Physics: acceleration) Average acceleration is defined as the change of velocity  divided by the time taken to make the change, as shown in the following formula: a = (v1 - v0)/t  Write a program that prompts the user to enter the starting velocity v0 in meters/ second, the ending velocity v1 in meters/second, and the time span t in seconds, and  displays the average acceleration.  #Beginner In gcc c++ compiler using namespace std; #include<iostream> using namespace std; int main() { float  velocity1,velocity0,time,acceleration; cout<< "Enter velocity0 m/s velocity1 m/s time /s :" ; cin>>velocity0>>velocity1>>time; acceleration=(velocity1-velocity0)/time; cout<< "The avrage acceleration is " <<acceleration; return 0; } copy Output Enter velocity0 m/s velocity1 m/s time /s :5 50 4 The avrage acceleration is 11.25 [Program finished] Need of Programmer Need of...

Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water.

Image
(Science:calculating energy ) Write a program that calculates the energy needed to  heat water from an initial temperature to a final temperature. Your program should  prompt the user to enter the amount of water in kilograms and the initial and final  temperatures of the water. The formula to compute the energy is Q = M * (finalTemperature – initialTemperature) * 4184  where M is the weight of water in kilograms, temperatures are in degrees Celsius, and  energy Q is measured in joules.  #Beginner In gcc c++ compiler using namespace std; #include<iostream> using namespace std; int main() { float M,finalTemperature,initialTemperature; cout<< "Enter te amount of water in kilograms :" ; cin>>M; cout<< "Enter the initial temperature :" ; cin>>initialTemperature; cout<< "Enter te finalTemperature :" ; cin>>finalTemperature; float Q=M*(finalTemperature-initialTemperature)*4184; cout<< "Th...

Write a program that prompts the user to enter v in meters/second (m/s) and the acceleration a in meters/second squared (m/s²), and displays the minimum runway length.

Image
(Physics: finding runway length) Given an airplane’s acceleration a and take-off  speed v, you can compute the minimum runway length needed for an airplane to take  off using the following formula: length = v²/2a  Write a program that prompts the user to enter v in meters/second (m/s) and the accel- eration a in meters/second squared (m/s²), and displays the minimum runway length. #Beginner In gcc c++ compiler using namespace std; #include<iostream> using namespace std; int main() { float speed,acceleration,length; cout<< "Enter speed and acceleration :" ; cin>>speed>>acceleration; length=( float )(speed*speed)/(2*acceleration); cout<< "The minimum runway length for this airplane is :" <<length; return 0; } copy Output Enter speed and acceleration :60 3.5 The minimum runway length for this airplane is :514.286 [Program finished] Need of Programmer Need of Programmer

Financial application c++ program

Image
(Financial application: compound value) Suppose you save $100 each month into a  savings account with the annual interest rate 5%. Thus, the monthly interest rate is  0.05/12 = 0.00417. After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417   After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252   After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507   and so on.  Write a program that prompts the user to enter a monthly saving amount and displays  the account value after the sixth month #Beginner In gcc c++ compiler using namespace std; #include<iostream> using namespace std; int main() { float amount,total=0; cout<< "Enter te monthly saving amount $ :" ; cin>>amount; total=amount*(1+0.00417); //1st total=(amount+total)*(1+0.00417); //2nd total=(amount+total)*(1+0.00417); //3rd total=(...

Write a program that prompts the user to enter two points (x1, y1) and (x2, y2) and displays their distance between them.The formula for computing the distance is

Image
(Geometry: distance of two points) Write a program that prompts the user to enter  two points (x1, y1) and (x2, y2) and displays their distance between them.The formula for computing the distance is  √ (x2 - x1)²+ (y2 - y1)² . Note that you  can use pow(a, 0.5) to compute √a.  #Beginner In gcc c++ compiler using namespace std; #include<iostream> #include<cmath> using namespace std; int main() { float x1,y1,x2,y2; cout<< "Enter x1 and y1 :" ; cin>>x1>>y1; cout<< "Enter x2 and y2 :" ; cin>>x2>>y2; float distance=pow((pow(x2-x1,2))+pow(y2-y1,2),0.5); cout<< "The distance between the two points is :" <<distance; return 0; } copy Output Enter x1 and y1 :1 9 Enter x2 and y2 :3 -5 The distance between the two points is :14.1421 [Program finished] Need of Programmer Need of Programmer