Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Allow the user to enter a decimal number which will represent the number of gall

ID: 3678990 • Letter: A

Question

Allow the user to enter a decimal number which will represent the number of gallons of gasoline and then convert them to liters. 1 gallon is equivalent to 3.7854 liters. Sample Interaction Please enter the number of gallons of gasoline: 100 Original number of gallons is 100 100 gallons is the equivalent of 378.54 liters Thanks for playing Allow the user to enter the initial of their first name and display a triangle using die letter that was entered by the user The character displayed must be the one that was entered by the user For example, if the user enters the D then your output should look as follows

Explanation / Answer

Here I am assuming that the languarge of implementation is C++

1)

Code:

#include <iostream>
#include <cstdlib>


using namespace std;

int main ()
{
int no_of_gallons;
float litres_amt; //final amount in litre
cout<<"Please enter the number of gallons of gasoline"<<endl;
cin>> no_of_gallons; //reading from user
cout<<"Original number of gallons is: "<< no_of_gallons<<endl;
litres_amt = 3.7854 *no_of_gallons;//calculating amount in litre
cout<<no_of_gallons<<" gallons is the equivalent of "<<litres_amt<<"litres "<<endl;
cout<<"Thanks for playing";
}

Sample Input and Output:

Please enter the number of gallons of gasoline
100
Original number of gallons is: 100
100 gallons is the equivalent of 378.54litres

2)

code:

#include <iostream>
#include <cstdlib>


using namespace std;

int main ()
{
char c;
cout<<"Please enter the initial character of your first name"<<endl;
cin>> c; //reading from user
cout<<" "<<c<<" "<<endl;
cout<<" "<<c<<" "<<c<<endl;
cout<<" "<<c<<" "<<c<<endl;
cout<<" "<<c<<" "<<c<<" "<<endl;
cout<<c<<c<<c<<c<<c<<c<<c<<c<<c<<endl;
}

If you have any doubt then please comment below

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote