//Exemplo EXERC04A

Propaganda
Material de Aulas Java-volume 1
//Exemplo EXERC04A.java
import java.io.*;
import java.text.DecimalFormat;
public class EXERC04A {
public static void main(String args[]) {
float TEMPO, VELOCIDADE, DISTANCIA, LITROS_USADOS;
DecimalFormat df = new DecimalFormat();
System.out.println();
System.out.print("Entre com o tempo .......: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
TEMPO = Float.parseFloat(br.readLine()); }
catch (Exception e) {
TEMPO = 0;
}
System.out.print("Entre com a velocidade ...: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
VELOCIDADE = Float.parseFloat(br.readLine()); }
catch (Exception e) {
VELOCIDADE = 0;
}
DISTANCIA = TEMPO * VELOCIDADE;
LITROS_USADOS = DISTANCIA / 12;
df.applyPattern("0.00");
System.out.print("\nVelocidade ........:
System.out.print("\nTempo .............:
System.out.print("\nDistância .........:
System.out.print("\nLitros Usados .....:
"
"
"
"
+
+
+
+
df.format(VELOCIDADE));
df.format(TEMPO));
df.format(DISTANCIA));
df.format(LITROS_USADOS));
System.out.println();
}
}
Prof. Walcyr
1
Material de Aulas Java-volume 1
//Exemplo EXERC04B.java
import java.io.*;
import java.text.DecimalFormat;
public class EXERC04B {
public static void main(String args[]) {
float C, F;
DecimalFormat df = new DecimalFormat();
System.out.println();
System.out.print("Entre com a temperatura em Celsius .......: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
C = Float.parseFloat(br.readLine()); }
catch (Exception e) {
C = 0;
}
F = (9 * C + 160) / 5;
df.applyPattern("0.00");
System.out.print("\nTemperatura em Fahrenheit ........: " + df.format(F));
System.out.println();
}
}
//Exemplo EXERC04H.java
import java.io.*;
import java.text.DecimalFormat;
public class EXERC04H {
public static void main(String args[]) {
double V, R, A;
DecimalFormat df = new DecimalFormat();
System.out.println();
System.out.print("Entre com o raio da lata ........: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
R = Float.parseFloat(br.readLine()); }
catch (Exception e) {
R = 0;
}
System.out.print("Entre com a altura da lata ......: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
A = Float.parseFloat(br.readLine()); }
catch (Exception e) {
A = 0;
}
V = 3.141592653589793 * R * R * A;
df.applyPattern("0.00");
System.out.print("\nO volume da lata ........: " + df.format(V));
System.out.println();
}
}
Prof. Walcyr
2
Material de Aulas Java-volume 1
//Exemplo EXERC04I.java
import java.io.*;
import java.text.DecimalFormat;
public class EXERC04I {
public static void main(String args[]) {
double P, D, R;
DecimalFormat df = new DecimalFormat();
System.out.println();
System.out.print("Entre com a densidade da esfera ........: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
D = Float.parseFloat(br.readLine()); }
catch (Exception e) {
D = 0;
}
System.out.print("Entre com o raio da esfera .............: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
R = Float.parseFloat(br.readLine()); }
catch (Exception e) {
R = 0;
}
P = D * 4 * 3.141592653589793 * R * R * R / 3;
df.applyPattern("0.00");
System.out.print("\nO peso da esfera ........: " + df.format(P));
System.out.println();
}
}
Prof. Walcyr
3
Material de Aulas Java-volume 1
//Exemplo EXERC04J.java
import java.io.*;
import java.text.DecimalFormat;
public class EXERC04J {
public static void main(String args[]) {
double A, B, AUX;
DecimalFormat df = new DecimalFormat();
System.out.println();
System.out.print("Entre com o valor de A .....: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
A = Float.parseFloat(br.readLine()); }
catch (Exception e) {
A = 0;
}
System.out.print("Entre com o valor de B .....: ");
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
B = Float.parseFloat(br.readLine()); }
catch (Exception e) {
B = 0;
}
AUX = A;
A = B;
B = AUX;
df.applyPattern("0.00");
System.out.print("\nO valor de A ....: " + df.format(A));
System.out.print("\nO valor de B ....: " + df.format(B));
System.out.println();
}
}
Prof. Walcyr
4
Download