Created
December 25, 2019 06:01
-
-
Save guibranco/83a2db183b22fbdfd2424bf7095647f4 to your computer and use it in GitHub Desktop.
Resposta para o grupo Programação Web - Ogaiht Santos - https://www.facebook.com/groups/355210561271853/permalink/2475777935881761/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <math.h> | |
#include <stdlib.h> | |
int main() { | |
//A = valor do litro de Alcool | |
//G = valor do litro de Gasolina | |
//D = valor do litro de Diesel | |
//O = opção escolhida | |
//V = valor de litros solicitado | |
//R = resultado | |
double A, G, D, V, R; | |
char O; | |
A = 1.9; | |
G = 2.5; | |
D = 1.66; | |
printf("===================\r\n"); | |
printf("A\tAlcool\r\n"); | |
printf("G\tGasolina\r\n"); | |
printf("D\tDiesel\r\n"); | |
printf("Informe a opcao:"); | |
scanf("%s", &O); | |
printf("===================\r\n"); | |
printf("Informe quantos litros:"); | |
scanf("%lf",&V); | |
printf("===================\r\n"); | |
switch(O){ | |
case 'A': | |
R = (V > 20 ? A * 0.95 : A * 0.97) * V; | |
break; | |
case 'G': | |
R = (V > 20 ? G * 0.94 : G * 0.96) * V; | |
break; | |
case 'D': | |
R = (V > 25 ? D * 0.96 : D) * V; | |
break; | |
default: | |
printf("Opção inválida de combustivel!"); | |
} | |
printf("Litros: %f\r\nR$ %f", V, R); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment