question archive Ask the student for their name
Subject:Computer SciencePrice:2.89 Bought3
Ask the student for their name.
Ask the student which formula they're solving for: S for Speed, V for Velocity, or Q to Quit
If the student chooses speed, then the code should ask them "which variable they are solving: Speed, distance or time. According to the choice of the student, you need to provide an equation that solves their choice. For example: If the student chooses the time, then you need to ask the student for the speed and distance and use distance/speed to solve for time and apply a an output to the user.
You will be using multiple if/else if/else statements for this code. So start on the outside (speed, velocity, quit) and work your way in.
The program is as below.
#include <iostream> using namespace std; int main() { cout<<"Select formula to solve: S for Speed, V for Velocity, or Q to Quit: "; int d,v,t,s; char a,b,c; cin>>a; if(a=='S'){ cout<<"Select variable for solving: S for Speed, D for distance, T for time.: "; cin>>b; if(b=='S'){ cout<<"Enter distance: "; cin>>d; cout<<"Enter time: "; cin>>t; s=d/t; cout<<"Speed: "<<s; } else if(b=='D'){ cout<<"Enter speed: "; cin>>s; cout<<"Enter time: "; cin>>t; d=s*t; cout<<"Distance: "<<d; } else if(c=='T'){ cout<<"Enter distance: "; cin>>d; cout<<"Enter speed: "; cin>>s; t=d/s; cout<<"Time: "<<t; } } else if(a=='V'){ cout<<"Select variable for solving: V for velocity, D for displacement, T for time.: "; cin>>c; if(c=='V'){ cout<<"Enter displacement: "; cin>>d; cout<<"Enter time: "; cin>>t; v=d/t; cout<<"Velocity: "<<v; } else if(c=='D'){ cout<<"Enter velocity: "; cin>>v; cout<<"Enter time: "; cin>>t; d=v*t; cout<<"Displacement: "<<d; } else if(c=='T'){ cout<<"Enter displacement: "; cin>>d; cout<<"Enter velocity: "; cin>>v; t=d/v; cout<<"Time: "<<t; } } else if(a=='Q'){ cout<<"Quiting - Thank you"; } return 0; }
please see the attached file for the complete solution.