fernandosantos1
Membro
eu sou novo nisto tou a tirar um curso de informatica mas verdade seja dita isto pra mim e chines.
o trabalho final e usar um switch para juntar 4 areas de solidos ate ai tudo bem depois e ke a porca torce o rabo eu fiz com o do while e ai pedia ke me ajudassem e ke para alem disso tenho ke por um while para ke se algum utilizador puser alguma coisa ke n seja s/n volta ao menu agradecia muito a vossa ajuda junto ponho o codigo.
o trabalho final e usar um switch para juntar 4 areas de solidos ate ai tudo bem depois e ke a porca torce o rabo eu fiz com o do while e ai pedia ke me ajudassem e ke para alem disso tenho ke por um while para ke se algum utilizador puser alguma coisa ke n seja s/n volta ao menu agradecia muito a vossa ajuda junto ponho o codigo.
Código:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
#include[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]<iostream>
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] std;[/COLOR]
[COLOR=#000000][/COLOR]
[COLOR=#000000][/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#000000] main (){[/COLOR]
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Areas;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Pi = 3.14159265F;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]float[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] area, base, altura, ladomaior, ladomenor, radius,lado;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]char[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] menu = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'s'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]do[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Qual a area que deseja saber?\n1.Circulo\n2.Quadrado\n3.Rectangulo\n4.Triangulo\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> Areas;
system ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"cls"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Areas){
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 1:
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Qual o raio do circulo?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> radius;
area = Pi *( radius * radius);
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"A area e' "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << area <<endl;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 2:
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"qual o tamanho do lado? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> lado;
area=lado*lado;
cout<<[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" A area e "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] <<area <<endl;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 3:
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Qual o tamanho do lado maior? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> ladomaior;
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Qual o tamanho do lado menor? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> ladomenor;
cout <<[/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" A area do rectangulo e "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] <<(ladomaior*ladomenor) <<endl;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 4:
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" insira o tamanho da base? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> base;
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" insira o tamanho da altura? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> altura;
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]" A area do triangulo e "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << (base*altura/2) <<endl;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"pretende continuar[s/n]? "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]<< endl;
cin >> menu ;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Qual a area que deseja saber?\n1.Circulo\n2.Quadrado\n3.Rectangulo\n4.Triangulo\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
cin >> Areas;
system ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"cls"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
} [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ( Areas != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'s'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'S'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'n'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] && != [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]'N'[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);{
cout << [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"pretende continuar[s/n]?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] << endl;
cin >> menu;
}
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 0;
}
[/SIZE]
Última edição pelo moderador: