Can someone help me with this C++ program?

C++ program that displays a menu allowing the user to select air, water, steel. After the user has made a selection, he should be asked to enter the distance a sound wave will travel in the selected medium, then whether this distance is in feet or miles. The program will display the amount of time it will take for sound to travel this distance in seconds.

constants are

Air = 1100 feet per second

Water = 4900 feet per second

Steel = 16400 feet per second

the distance may be a whole number or may not be. If the user enter a negative number use its absolute value.

The feet or miles choice will be a single char. Valid values are f or F for feet and m or M for miles. However the program should consider m or M to mean miles and any other character to mean feet.

Ouput should include the entered medium,, distance in Feet and time. the time should be rounded 4 decimal places, but distance should be rounded to one decimal place.

If you could help with this I would appreciate it! I started but i got stuck but this is what I know is for sure good.

#include <iostream>

#include <cmath>

#include <cstdlib>

#include <iomanip>

using namespace std;

int main()

{

const int Air = 1100;

const int Water = 4900;

const int Steel = 16400;

int choice;

double distance, time;

int feet, miles;

double speedOfSoundAir, speedOfSoundWater, speedOfSoundSteel;

cout << "How long will it take?" <<endl;

cout << "Enter the medium through wich sound is traveling: " <<endl;

cout << "\t1. Air " <<endl;

cout << "\t2. Water " <<endl;

cout << "\t3. Steel " <<endl;

cout << "Enter choice (1 - 3) : ";

cin >> choice;

cout << fixed << showpoint << setprecision(4);

switch (choice)

{

case 1:

cout << "Enter the distance a sound wave will travel in the selected medium: ";

cin >> distance;

cout << "Is the distance in feet or miles? Enter f for feet and m for miles: ";

cin >> feet >> miles;

return 0;

}

Help!!!

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 EBIN.TIPS - All rights reserved.