I have this c++ program that i have to create but i am stuck on it.
Code:
#include <iostream>
using namespace std;
//function to convert feet and inches to meters
void feetInchToMeters(int feet, int inch, double *meter)
{
*meter = feet*0.3048 + (0.3048/12)*inch;
}
//function to convert meters to feet and inches
void metersToFeetInch(int *feet, int *inch, double meter)
{
*feet = meter/0.3048;
*inch = (meter*39.301)-(*feet)*12;//1 meter = 39.301 inches
}
int main()
{
int feet;
int inch;
double meter;
int option;
do{
cout<<"1. Convert feet and inches to meters \n2. Convert
meters to feet and inches \n3. Exit"<<endl;
cout<<"Select option :";
cin>>option;
if(option==1)
{
cout<<"Enter the value in feet (integer value) :";
cin>>feet;
cout<<"Enter the value in inches (integer value):";
cin>>inch;
feetInchToMeters(feet, inch, &meter);
cout<<feet<<" feet and "<<inch<<" inches
equals to "<<meter<<"
meters"<<endl<<endl;
}
else if(option==2)
{
cout<<"Enter the value in meters :";
cin>>meter;
metersToFeetInch(&feet, &inch, meter);
cout<<meter<<" meters equals to "<<feet<<"
feet and "<<inch<<"
inches"<<endl<<endl;
}
else if(option!=3)
{
cout<<"Invalid option entered"<<endl<<endl;
}
}while(option!=3);
}
Output:
I have this c++ program that i have to create but i am stuck on it....
. Write a program that reads in a length in feet and inches and outputs the equivalent length in meters and centimeters. Use at least three functions: one for input, one or more for calculating, and one for output. Include a loop that lets the user repeat this computation for new input values until the user says he or she wants to end the program. There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches...
C++ programming language , I need help writing the code . Please explain if you can . Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...
Write a single C++ program that performs the following conversion (The modulus divide will help you get the remainder as shown in class) 39 / 12 = 3 and 39 % 12 = 3, so 3 feet 3 inch(es) Height conversion 1 meter = 39 inches 12 inches = 1 foot Ask/Prompt the user to enter in the height in meters, convert and output the result in feet and inches Example 1 meters as input should produce 3 feet (foot)...
CSC110 EXAM06A Objects NAME: class meters2feet private double meters; public void setMeters (double m) {meters=m ; } public double getMeters ){ return meters;} pubic double convert2feet ( ) { return (meters*3.2808) ; } NOTE: This class cannot be changed must be used as is C class meters2inches private double meters; public void setMeters (double m) {mete rs=m ; } public double getMeters () { return meters ; } pubic double convert2inches ( ) { return (meters*39.3701) ; NOTE: This class...
I am using C++ Start with the distance.cpp file on the website. Fill in the missing functions to enable the program to compile and correctly find determine which entered distance is larger. The user can either enter it in meters labeled with an “m”, or in feet and inches labeled with and ' and “. You may not change main(), we will check to ensure it is exactly the same. The meters and inches can be doubles, but the feet...
c++ Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again.
IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...
Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...
(Must be in C#) (Console will be my choice) Create a program called NarwhalCalc that will be used to compute a narwhal's weight in tons based on its length in feet. Your program must use a method to do this and you must write this method. Your method must be called FeetToTons and the method must accept a parameter called feet (type double). The method should then use the formula shown below to calculate the narwhal's weight, then RETURN (not...
I need help writing a C programming code. I am trying to create a program that returns ANY given number's decimal value as an Integer (Whole number). Examples: User input: 0.35 Output: 35 User input: 1.465 Output: 465 User input: 10.6054 Output: 6054