(URI) Cálculo Simples - Solução

import java.io.*;
import java.util.*;

class Main  {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        double total = 0.0;
       
        for (int i = 0; i < 2; i++) {
            String linha = br.readLine();
           
            StringTokenizer tokenizer = new StringTokenizer(linha);
            int codigo = Integer.parseInt(tokenizer.nextToken());
            int qte = Integer.parseInt(tokenizer.nextToken());
            double preco = Double.parseDouble(tokenizer.nextToken());
           
            total += qte*preco;
        }       
       
        System.out.print("VALOR A PAGAR: R$ ");
        System.out.printf("%.2f\n", total);
    }
}

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução