URI Online Judge | 1134
Type of Fuel
Adapted by Neilor Tonin, URI  Brazil
 Brazil
Timelimit: 1 Brazil
 Brazil
A gas station wants to determine which of their products is the preference of their customers. Write a program to read the type of fuel supplied (coded as follows: 1. Alcohol 2. Gasoline 3. Diesel 4. End). If you enter an invalid code (outside the range of 1 to 4) must be requested a new code (valid until). The program will end when the inserted code is the number 4.
Input
The input contains only integer and positive values.
Output
It should be written the message: "MUITO OBRIGADO" and the amount of customers who fueled each fuel type, as an example.
| Input Sample | Output Sample | 
| 8 1 7 2 2 4 | MUITO OBRIGADO Alcool: 1 Gasolina: 2 Diesel: 0 | 
URI Online Judge Solution 1134 || Type of Fuel in C Language
#include<stdio.h>
int main(){
       int X = 0, fuel = 0,
            customerAlcohol = 0,
            customerGasolin = 0,
            customerDisel = 0;
        while (X != 4) {
            scanf("%d", &X);
            if (X == 1) {
                customerAlcohol+=1;
            }else if (X == 2) {
                customerGasolin += 1;
            }else if (X == 3) {
                customerDisel += 1;
            }
        }
        //Alcool: 1 Gasolina: 2 Diesel: 0
        printf("MUITO OBRIGADO\n");
        printf("Alcool: %d\n", customerAlcohol);
        printf("Gasolina: %d\n", customerGasolin);
        printf("Diesel: %d\n", customerDisel);
}URI Online Judge Solution 1134 || Type of Fuel in Java Language
import java.io.IOException;import java.util.Scanner;  public class Main {      public static void main(String[] args) throws IOException {         int X = 0, fuel = 0, customerAlcohol = 0, customerGasolin = 0, customerDisel = 0;        Scanner input = new Scanner(System.in);                                   while (X != 4) {            X = input.nextInt();            if (X == 1) {                customerAlcohol+=1;            }else if (X == 2) {                customerGasolin += 1;            }else if (X == 3) {                customerDisel += 1;            }                     }        //Alcool: 1 Gasolina: 2 Diesel: 0        System.out.print("MUITO OBRIGADO\n");        System.out.print("Alcool: "+customerAlcohol+"\n");        System.out.print("Gasolina: "+customerGasolin+"\n");        System.out.print("Diesel: "+customerDisel+"\n");      }  }Download code from Dropbox
URI Main question link
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks