Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Conversor de Temperaturas
- * Feito Por: Diego Charles
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main () {
- inicio:
- system("clear");
- printf("\n |-------------------------------------|");
- printf("\n | Conversor de Temperaturas |");
- printf("\n |-------------------------------------|");
- printf("\n\n Que Tipo de Conversao Voce Deseja Fazer?\n");
- printf("\n (1) Celsius Para Farenheit (4) Farenheit Para Celsius");
- printf("\n (2) Celsius Para Kelvin (5) Kelvin Para Celsius");
- printf("\n (3) Farenheit Para Kelvin (6) Kelvin Para Farenheit");
- int operacao;
- printf("\n\n Digite o Valor da Operacao: ");
- scanf("%d", &operacao);
- float celsius,faren,kelvin;
- switch (operacao){
- /* (1) CELSIUS > FARENHEINT */
- case 1 :
- printf("\n\n Digite o Valor em Celsius: ");
- scanf("%f", &celsius);
- if (celsius < (-273.15)) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor medido em Celsius eh: -273");
- printf("\n\n Digite um valor correto em Celsius: ");
- scanf("%f", &celsius);
- }
- else {
- printf("\n\n Resolvendo: F = (%.2f * 1.8) + 32", celsius);
- faren = (celsius * 1.8) + 32;
- printf("\n\n Resultado: ");
- printf(" (%.2f)ºC = (%.2f)ºF \n\n", celsius,faren);
- }
- break;
- /* (2) CELSIUS > KELVIN */
- case 2 :
- printf("\n\n Digite o Valor em Celsius: ");
- scanf("%f", &celsius);
- if (celsius < 0) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor medido em Celsius eh: -273");
- printf("\n\n Digite um valor correto em Celsius: ");
- scanf("%f", &celsius);
- }
- else {
- printf("\n\n Resolvendo: K = %.2f + 273", celsius);
- kelvin = celsius + 273;
- printf("\n\n Resultado: ");
- printf("(%.2f)ºC = (%.2f)K \n\n", celsius,kelvin);
- }
- break;
- /* (3) FARENHEINT > KELVIN */
- case 3 :
- printf("\n\n Digite o Valor em Farenheit: ");
- scanf("%f", &faren);
- if (faren < (-273.15)) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor medido em Farenheit eh: X");
- printf("\n\n Digite um valor correto em Farenheit: ");
- scanf("%f", &faren);
- }
- else {
- printf("\n\n Resolvendo: K = (%.2f + 459,27) * (5/9)", faren);
- kelvin = (faren + 459,27) * (5/9);
- printf("\n\n Resultado: ");
- printf(" (%.2f)ºF = (%.2f)K \n\n", faren,kelvin);
- }
- break;
- /* (4) FARENHEINT > CELSIUS */
- case 4 :
- printf("\n\n Digite o Valor em Farenheit: ");
- scanf("%f", &faren);
- if (faren < (-273.15)) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor medido em Farenheit eh: X");
- printf("\n\n Digite um valor correto em Farenheit: ");
- scanf("%f", &faren);
- }
- else {
- printf("\n\n Resolvendo: C = (5/9) * (%.2f - 32)", faren);
- celsius = (5/9) * (faren - 32);
- printf("\n\n Resultado: ");
- printf(" (%.2f)ºF = (%.2f)ºC \n\n", faren,celsius);
- }
- break;
- /* (5) KELVIN > CELSIUS */
- case 5 :
- printf("\n\n Digite o Valor em Kelvin: ");
- scanf("%f", &kelvin);
- if (kelvin < 0) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor Medido em Kelvin Eh: 0 (Zero Absoluto)");
- printf("\n\n Digite um valor correto em Kelvin: ");
- scanf("%f", &kelvin);
- }
- else {
- printf("\n\n Resolvendo: C = %.2f - 273", kelvin);
- celsius = kelvin - 273;
- printf("\n\n Resultado: ");
- printf(" (%.2f)K = (%.2f)ºC \n\n", kelvin,celsius);
- }
- break;
- /* (6) KELVIN > FARENHEIT */
- case 6 :
- printf("\n\n Digite o Valor em Kelvin: ");
- scanf("%f", &kelvin);
- if (kelvin < 0) {
- printf("\n Valor Incorreto!");
- printf("\n O Menor Valor Medido em Kelvin Eh: 0 (Zero Absoluto)");
- printf("\n\n Digite um valor correto em Kelvin: ");
- scanf("%f", &kelvin);
- }
- else {
- printf("\n\n Resolvendo: F = (%.2f * (9/5)) - 459.67 ", kelvin);
- faren = (kelvin * (9/5)) - 459.67;
- printf("\n\n Resultado: ");
- printf(" (%.2f)K = (%.2f)ºF \n\n", kelvin,faren);
- }
- break;
- /* Informa erro se o dado inserido for diferente das opçoes */
- default : printf("\n\n ERRO - Operacao Invalida!");
- }
- /* Voltar ao Inicio */
- int repetir;
- printf("\n\n Deseja Executar Outra Operacao? (s/n): ");
- scanf("%d", &repetir);
- if (repetir = 's') { goto inicio; }
- else { return 0; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement