
No puedo encontrar mi error en el programa
Publicado por Rocio (2 intervenciones) el 19/11/2016 07:16:43
hola, soy nueva aprendiendo c++ y me esta volviendo loca, me gustaria saber si vosotros me pueden ayudar a resolver mi problema. No puedo encontrar mi error en el programa
aqui les dejo lo que hasta ahora e avanzado:
por adelantado mil gracias :)
aqui les dejo lo que hasta ahora e avanzado:
por adelantado mil gracias :)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// ProjectThree.cpp : Defines the entry point for the console application.
// programa que calcula el area y perimetro del circulo traingulo cuadrado y rectangulo
#include<iostream>
#include<iomanip>
#include "stdafx.h"
using namespace std;
void calculateCircle(double);
void calculateTriangle(double);
void calculateSquare(double);
void calculateRectangle(double);
int main()
{
int choice;
do
{
cout << "\n\t\tGeometry calculator\n\n";
cout << "1. Circle\n";
cout << "2. Triangle\n";
cout << "3. Square\n";
cout << "4. Rectangle\n";
cout << "5. Quit the program\n";
cout << "Enter your choice:\n";
cin >> choice;
if (choice >= 1 && choice <= 4)
{
switch (choice)
{
case 1:calculateCircle();
break;
case 2:calculateTriangle();
break;
case 3:calculateSquare();
break;
case 4:calculateRectangle();
}
if (choice != 4)
{
cout << "The valid choices are 1 through 5.\n";
cout << "Try again.\n";
}
}
}
while (choice != 5);
return 0;
}
void calculateCircle(double area, double radius, double cir)
{
const double pi = 3.14159;
cout << fixed << showpoint << setprecision(2);
cout << "This function calculates the area of";
cout << " a circle.\n";
cout << "Enter the radius of the circle:\n";
cin >> radius;
area = pi * radius * radius;
cout << "The area is " << area << endl;
cir = 2.0 * pi * radius;
cout << "The circumference is" << cir << endl;
}
void calculateTriangle(double base, double height, double area)
{
cout << fixed << showpoint << setprecision(2);
cout << "This function calculates the area of";
cout << "a triangle\n";
cout << "Enter the base of the triangle:\n";
cin >> base;
cout << "Enter the height of the traingle\n";
cin >> height;
area = (base * height) / 2;
cout << " The area of the triangle is" << area << endl;
}
void calculatesSquare(double area, double side, double perimeter)
{
cout << fixed << showpoint << setprecision(2);
cout << "This function calculates the area of";
cout << "a square\n";
cout << "Enter the side of the square:\n";
cin >> side;
area = side * side;
cout << "The area is " << area << endl;
perimeter = 4.0 * side;
cout << "The perimeter is " << perimeter << endl;
}
void calculateRectangle(double area, double length, double width, double perimeter)
{
cout << fixed << showpoint << setprecision(2);
cout << "This function calculates the area of";
cout << "a rectangle";
cout << "Enter the length of the rectangle:\n";
cin >> length;
cout << "Enter the width of the rectangle:\n";
cin >> width;
area = length * width;
cout << "The area of the rectangle is " << area << endl;
perimeter = (2.0 * length) + (2.0 * width);
cout << "The perimeter is " << perimeter << endl;
}
Valora esta pregunta


0