I wrote the following program (it works), but it only displays theresults in a w
ID: 3612753 • Letter: I
Question
I wrote the following program (it works), but it only displays theresults in a whole number. How would I tell it to display theanswer to include two decimals?// fahren.cpp
// demonstrates cin, newline
#include <iostream>
using namespace std;
int main()
{
int length; //for temperature in fahrenheit
cout << "Enter length in feet: ";
cin >> length;
int width; //for temperature in fahrenheit
cout << "Enter width in feet: ";
cin >> width;
int area = (length * width) / (640 * 640);
cout << "Equivalent in Square Acres is: "<< area << ' ';
system("pause");
return 0;
}
Thanks!!!
Explanation / Answer
/*the changes are highlighted in the program. I am using Microsoft visual c++ 6.0..and this program is working asrequired. if there are any errors..feel free to ask me */ #include #include using namespace std; int main() { float length; //for temperaturein fahrenheit cout > length; float width; //for temperaturein fahrenheit cout > width; //cout.precision(2); float area = (length * width) / (640 *640); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.