Need help figuring out how to compile the second half of this code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// Simple Geometric Calculator
#include <iostream>
using namespace std;
int main()
{
int sideOne = 3;
int sideTwo = 4;
int area = 0;
area = (sideOne*sideTwo)/2; //Logic to calculate the area of a triangle
cout<<"The sides of the triangle measure "<<sideOne<<" and "<<sideTwo<<"."<<" The area is "<<area<<"."<<endl;
return 0;
|
the second half of the code the goal is to display pretty much what the first half displays, but the values are multiplied by 5.0 and must display as a double.
the instructions are as followed:
Create a program that calculates and outputs the area of a triangle under two circumstances.
The program will print the area out twice.
For the first output:
The triangle sides measure 3 and 4 at the beginning of the program.
Integers variables will be used to hold the values of the length of the sides and the area of the triangle.
Initially the area variable will hold a value of (be initialized to) zero.
The program then calculates the area of the triangle and places the result of the calculation in the area variable.
The value of the three variables holding the side lengths and area are to then be output as shown below.
For the second output:
Double variables are to be used to hold the values of the length of the sides and the area of the triangle.
The side variables will be initialized to zero.
The program then multiplies the integer length values by five and places them in the double type side variables.
The program then calculates the area of the triangle using the new double type side values and places the result in the new double type area variable.
The value of the double type variables holding the side lengths and area are to be output as shown below.
The output should be with a single decimal place after the decimal point.
The program should produce the following output:
The sides of the triangle measure 3 and 4. The area is 6.
The sides of the triangle measure 15.0 and 20.0. The area is 150.0