4
I’m having a hard time writing this exercise in the Java Language, using the Eclipse IDE:
The director of a state school in the city of São Paulo is terrified by the absurd consumption of water that has been occurring monthly. In order to gather information that leads her to make cost containment decisions, she hired you to develop a program that performs the reading of water consumption in the month, in m3, and inform the value of the account. Data: consider that each m3 is worth R$ 2.00; in addition, R$ 20.00 of sewage and 15% of taxes are added.
I’m not getting the program to perform the calculations. In my case I must first calculate the tax, then "throw" it in the formula to calculate the value of water consumption.
MY DOG
import java.io.IOException;
import java.util.Scanner;
public class Agua {
public static void main(String[] args) throws IOException {
int consumo;
int valore;
int imposto;
System.out.println("Informar o valor do consumo");
Scanner Leio = new Scanner(System.in);
consumo = Leio.nextInt();
imposto = (2 * consumo + 20) * 15/100;
System.out.println("O imposto é ");
System.out.println("Informe o valor do imposto");
valore = (2 * consumo + 20) + imposto;
System.out.println("O Valor é de: R$ ");
Leio.close();
}
}
I’m having difficulties in this exercise, because after I type the consumption value does not occur anything!
Below follows the formulas by Visualg where the cacules occur smoothly (crazy teacher wants Portugol/Visualg and Java)!
My second image is the screen in Eclipse after I inform the value of "consumption"
In case nothing appears on the screen, why you are not printing the variables. Your System.out.println is just printing the text. Try to put in the text
System.out.println("O imposto é " + imposto);
andSystem.out.println(O valor é de R$: " + valore);
– Viktor Hugo