Você está na página 1de 37

EX.

import java.util.Scanner;
public class idade {

public static void main(String[] args) {


Scanner leia = new Scanner(System.in);

double cont = 0; //declarando as variaveis


double soma = 0;
double n = 0;
while (n >= 0){
n = leia.nextInt(); //acumulador da soma das idades
if (n < 0) { //numeroo de individuos lidos
break;

soma+=n;
cont++;

}
double media= (soma / cont);
System.out.print(String.format("%.2f", media));

}
EX.2

import java.util.Scanner;

public class HomensMulheres {


public static void main(String[] args) {
int sexo, qtMulheres=0, qtHomens=0;
float altura, somaH=0, mediaHomens=0, maior=0, menor=0;

Scanner entrada = new Scanner(System.in);

for (int i=0; i<50; i++) {


System.out.print("Escolha o sexo da pessoa (1-Mulher, 2-Homem): ");
sexo = entrada.nextInt(); //variavel vazia
System.out.print("Digite a altura: ");
altura = entrada.nextFloat(); //variavel vazia

if (sexo == 1) {
qtMulheres++;

} else if (sexo == 2) {
qtHomens++;
somaH = somaH + altura;

} else {
System.out.println("Opção sexo inválido!");
}
if (altura > maior) {
maior = altura;

} else if (altura < menor){


menor = altura;
}
}
mediaHomens = somaH / qtHomens;

System.out.println("A maior altura do grupo é de " + maior + " m, e a menor é


de " + menor + " m");
System.out.println("A média de altura dos homens é " + mediaHomens + " m");
System.out.println("O número de homens é " + qtMulheres);

entrada.close();
}
}

EX.3

public class ConverterGraus {


public static void main(String[] args) {
double Farenheit;

// Constroi a tabela
for(Farenheit = 50; Farenheit <= 150; Farenheit++){

// System.out.printf("%dF = %.2fC"Farenheit + "F = " +


Formatador(ConveterFemC(Farenheit)) + "C");
System.out.printf("%.2fF = %.2fC\n", Farenheit,
ConveterFemC(Farenheit));
}
}

// Esta função faz a conversão entre os tipos de graus


private static double ConveterFemC(double Farenheit){
return (5.0 / 9.0) * (Farenheit - 32);
}

oudOu

public class ConverterGraus {


public static void main(String[] args) {

System.out.println( "Frenheit / Centigrados");


for (int f = 50; f <= 150; f++){
double c = 5.0 / 9 * (f - 32);

System.out.println(" / " + f + " / " + c + " / ");


}

}
EX.4

public class Main


{
public static void main(String[] args) {

double pc = 0.00;
double pv = 0.00;
double max = 1000.00;
double min = 1.00;
int x;
int l1 = 0;
int l2 = 0;
int ln = 0;
double lu;

//inicialização dos acumuladores

for (x = 0; x <= 100; x++){

pv = (Math.random()*(max-min+1)+min);
pc = (Math.random()*(max-min+1)+min);
lu = (pv/pc) * 100;
if (lu < 10){
l1 += 1;
}
else if (lu >= 10 && lu <= 20){
l2 += 1;
}
else{
ln += 1;
}
}
// exive (ou imprime) os resultados
System.out.println("menos 10% de lucro:" + l1);
System.out.println("entre 20% de lucro:" + l2);
System.out.println("mais de 20% de lucro:" + ln);
}
}
EX.5

public class Populacoes {

public static void main(String[] args) {

//delcaraçao das variaveis

double PaisA = 90000000; // 90 milhões

double PaisB = 200000000; // 200 milhões

int ContadorAnos = 0;

//inicializacai dis acumudadoree e constantes

while(PaisA < PaisB){

PaisA += ((PaisA * 3.0) / 100.0);

PaisB += ((PaisB * 1.5) / 100.0);

ContadorAnos++;

// System.out.println("País: A " + PaisA + " País B: " + PaisB);

System.out.println("Total de Anos: " + ContadorAnos);

}
}

EX.6

import java.util.Scanner;

public class Massa {

// Método principal do programa...

public static void main(String[] args) {

double MassaInicial = 0;

double MassaFinal = 0;

int Segundos = 0;
Scanner Entrada = new Scanner(System.in);

System.out.println("Informe a massa inicial em gramas.");

MassaInicial = Double.parseDouble(Entrada.nextLine());

MassaFinal = MassaInicial;

// Calcula a massa final do proutod usado...

while(MassaFinal > 0.5){

// System.out.println("Massa: " + MassaFinal);

MassaFinal /= 2;

Segundos += 50;

System.out.printf("Massa Inicial: %.2f\n", MassaInicial);

System.out.printf("Massa Final..: %.4f\n", MassaFinal);

System.out.println("Tempo Total.: " + FormataSegundos(Segundos));

// Transformando segundos em hora:minutos:segundos...

private static String FormataSegundos(int Seg){

int Hora, Minuto, Segundos;

Hora = (int)(Seg / (60 * 60));

Minuto = (int)((Seg - (Hora * 60 * 60)) / 60);

Segundos = (int)(Seg - (Hora * 60 * 60) - (Minuto * 60));

return String.format("%02d:%02d:%02d", Hora, Minuto, Segundos);

}
EX.7

public class Main


{
public static void main(String[] args) {

//iniciando as variaveis de turmas, alunos matriculados, ausentes e presents


int totalturmas = 14;

double alunosM;
int max;
int min;
int nt = 0;
int na = 0;
double poa = 0;
double qa = 0;
double pc = 0;
for (nt = 0; nt < totalturmas; nt++){
max = 60;
min = 15;
alunosM = (Math.random()*(max-min+1)+min);

//inicalizacao dos acumuladores gerais

for(na = 0; na < alunosM; na++){


max = 2; //contadores
min = 0; //total de turmas com ausencia > q 5%

//iniciando os acumuladores por turmas

poa = (Math.random()*(max-min+1)+min);
if (poa >= 1){
qa = 100/alunosM;
pc += qa;
}

}
System.out.println(Math.round(pc) + "%");
pc = 0;
}

}
}
EX.8

public class MyClass {


public static void main(String args[]) {

//declarando as variveis e seus respectivos valores

int npes = 2000;


int nneg = 0;
int nm = 0;
int nf = 0;
int nfpos = 0;
int nmneg = 0;
int min = 0; int max = 2; int x = 0;

double inputsex;
double inputopi;

//inicializacao dos acumuladores gerais

for (x = 0; x <= npes; x++){


inputsex = (Math.random()*(max-min+1)+min);
if (inputsex <= 1){
nm += 1;
inputopi = (Math.random()*(max-min+1)+min);
if (inputopi >= 1){
nfpos += 1;
}
else{
nneg += 1;
}
}

//verifica se a resposta da pessoa e sim ou não

else{
nf += 1;
inputopi = (Math.random()*(max-min+1)+min);
if (inputopi <= 1){
nmneg += 1;
nneg += 1;
}
}

//calcula os porcentuais

}
double pfpos = nfpos*100/nf;
double pmneg = nmneg*100/nm;
//resultados impressos

System.out.println("N de negativos: " + nneg);


System.out.println("N de homens: " + nm);
System.out.println("N de mulheres: " + nf);
System.out.println("N de homens - : " + nmneg);
System.out.println("N de mulheres + : " + nfpos);
System.out.println("% homens negativo: " + pmneg);
System.out.println("% mulheres positivo: " + pfpos);
}
}

EX.9

package demo;

import java.util.Scanner;

public class DemoTranslation {


public static void main(String[] args) {
int x, meses;
String8 sexo = new String8(15);
float mortos, defuntos, pormenordefunto, menordefunto = 0, masc
= 0, contpes = 0;
x = STDIN_SCANNER.nextInt();
sexo.copyFrom(STDIN_SCANNER.next());
String obj = "VAZIO";
while(!sexo.equals(obj)) {
contpes++;
var obj2 = "MASCULINO";
if(sexo.equals(obj2)) {
masc++;
}
meses = STDIN_SCANNER.nextInt();
if(meses < 24) {
menordefunto++;
}
sexo.copyFrom(STDIN_SCANNER.next());
}
mortos = contpes * 100 / x;
defuntos = masc * 100 / x;
pormenordefunto = menordefunto * 100 / x;
System.out.printf("PORCENTAGEM DE MORTOS = %.2f\n", mortos);
System.out.printf("PORCENTAGEM DE MASCULINOS MORTOS = %.2f\n",
defuntos);
System.out.printf("PORCENTAGEM DE MENOS DE 24 MESES = %.2f\n",
pormenordefunto);
}

public final static Scanner STDIN_SCANNER = new Scanner(System.in);


}
EX.10

public class Main


{
public static void main(String[] args) {

//Declarando as variaveis e os seus valores.

int max = 12;


int min = 0;
double canal = 1;
int c = 0;

//Numero de pessoas que estavam assistindo

double c4=0; //numero de pessoas vendo o canal 4


double c5=0; //numero de pessoas vendo o canal 5
double c7=0; //numero de pessoas vendo o canal 7
double c12=0; //numero de pessoas vendo o canal 12

double p4=0; //porcentagem de audiencia no canal 4


double p5=0; //porcentagem de audiencia no canal 5
double p7=0; //porcentagem de audiencia no canal 7
double p12=0; //porcentagem de audiencia no canal 12

//inicialização dos acumuladores e contadores

for (canal = 1; canal != 0; canal = Math.round(Math.random()*(max-min+1)+min)){


if (canal == 4){
c4 += 1;
c += 1;
}
if (canal == 5){
c5 += 1;
c += 1;
}
if (canal == 7){
c7 += 1;
c += 1;
}
if (canal == 12){
c12 += 1;
c += 1;
}
}

//Calculo das porcentagens das emissoras


p4 = c4*100/c;
p5 = c5*100/c;
p7 = c7*100/c;
p12 = c12*100/c;

// resultados

System.out.println(Math.round(p4)+"%");
System.out.println(Math.round(p5)+"%");
System.out.println(Math.round(p7)+"%");
System.out.println(Math.round(p12)+"%");

}
}

EX.11

public class MyClass {


public static void main(String args[]) {

//Decladando as variaveis e seus respectivos valores

long codcurso=1;
long max = 30;
long min = 0;
long rand = Math.round(Math.random()*(max-min+1)+min);
long nvagas = 0;
long candM = 0;
long candF = 0;
long candV = 0;
long pcF = 0;

//Inicialização para ver o maior numero de candidatos por vagas, acumuladores e condicoes
iniciais

for (codcurso = 1; codcurso != 0; codcurso = rand){


rand = Math.round(Math.random()*(max-min+1)+min);
min = 10;
max = 60;

nvagas = Math.round(Math.random()*(max-min+1)+min);
max = nvagas;
min = 0;

candM = Math.round(Math.random()*((max-1)-min+1)+min);
max = max - candM;
min = 0;

candF = Math.round(Math.random()*(max-min+1)+min);
max = 30;
min = 0;

candV = Math.round(nvagas/(candM+ candF));

pcF = candF * 100/(candM + candF);

//Impressão dos resultados

System.out.println("| Código de curso: " + codcurso);


System.out.println("| N de vagas: " + nvagas);
System.out.println("| N de candidatos por vaga: " + candV);
System.out.println("| Porcentagem de mulheres: " + pcF + "%");
System.out.println("| total de candidatos: " + (candM + candF));
}

}
}

EX.12

public class MyClass {


public static void main(String args[]) {

//Decladando as variaveis e seus respectivos valores

int nalunos = 0;
long matricula=10;
long nota1 = 0;
long nota2 = 0;
long nota3 = 0;
long notafinal = 0;
long notapos = 60;
long naulas = 0;
long naluasfreq = 0;
long notamturma = 0;
int alunosReprovados = 0;
int alunosausentes =0;
long max = 0;
long min = 0;
long maiornota = 0;
long menornota = 100;

//Maior numero de canditatos por vaga

for (nalunos = 0; nalunos <= 25; nalunos++){


// inicializaçao das condicoes iniciais

max = 99999;
min = 11111;
matricula = Math.round(Math.random()*((max)-min+1)+min);
System.out.println("SUA MATRICULA É: " + matricula);
max = 100;
min = 5;
nota1 = Math.round(Math.random()*((max)-min+1)+min);

if (nota1 >= maiornota){


maiornota = nota1;
}
if (nota1 <= menornota){
menornota = nota1;
}
nota2 = Math.round(Math.random()*((max)-min+1)+min);
if (nota2 >= maiornota){
maiornota = nota2;
}
if (nota2 <= menornota){
menornota = nota2;
}
nota3 = Math.round(Math.random()*((max)-min+1)+min);
if (nota3 >= maiornota){
maiornota = nota3;
}
if (nota3 <= menornota){
menornota = nota3;
}
notafinal = (nota1+nota2+nota3)/3;

System.out.println("SUA NOTA FINAL FOI: " + notafinal);


notamturma += notafinal;
max = 100;
min = 0;
naulas = Math.round(Math.random()*((max)-min+1)+min);

System.out.println("FREQUENCIA DAS AULAS" + naulas + " aulas");


if (notafinal <= 59){
System.out.println("ALUNO REPROVADO");
alunosReprovados += 1;
}
if (naulas <= 39){

System.out.println("ALUNO REPROVADO POR FALTA");


alunosReprovados += 1;
alunosausentes += 1;
}
if (notafinal <= 59 && naulas <= 39){

System.out.println("ALUNO REPROVADO");
alunosReprovados += 1;
}

//Impressão dos resultados

notamturma = notamturma/nalunos;
System.out.println("MAIOR NOTA: " + maiornota);
System.out.println("MENOR NOTA: " + menornota);
System.out.println(alunosReprovados + " ALUNOS REPROVADOS");
System.out.println("MÉDIA DA TURMA " + notamturma);
System.out.println(alunosausentes + " ALUNOS REPROVADOS POR FREQUENCIA ");

}
}

EX.13

public class MyClass {


public static void main(String args[]) {

//Declaracao das variaveis

long pKw=10;
long nconsumidor=1;
long qtdKw= 0;
long tipoconsu;
int max = 100;
int min = 0;
long mcons = 0;
long mincons = 10000;
long maxr = 0;
long maxc = 0;
long maxi = 0;
long cont = 0;
long soma = 0;

//Inicializacao dos acumuladores e condicoes de contorno

nconsumidor = Math.round(Math.random()*((max)-min+1)+min);
for (nconsumidor = 1; nconsumidor != 0; nconsumidor =
Math.round(Math.random()*((max)-min+1)+min)){
max = 100;
min = 0;
pKw = Math.round(Math.random()*((max)-min+1)+min);
qtdKw = Math.round(Math.random()*((max)-min+1)+min);

if (qtdKw >= mcons){


mcons = qtdKw;
}
if (qtdKw <= mincons){
mincons = qtdKw;
}
System.out.println("O consumidor devera pagar: R$" + pKw * qtdKw+".00");
max = 3;
min = 0;
tipoconsu = Math.round(Math.random()*((max)-min+1)+min);
if (tipoconsu == 1){
if (qtdKw >= maxr){
maxr = qtdKw;
}
}
if (tipoconsu == 2){
if (qtdKw >= maxc){
maxc = qtdKw;
}
}
if (tipoconsu == 3){
if (qtdKw >= maxi){
maxi = qtdKw;
}
}
cont += 1;
soma += qtdKw;
}

//Saida dos resultados finais

System.out.println("MAIOR QUANTIDADE CONSUMIDA: " +mcons+"Kw");


System.out.println("MENOR QUANTIDADE CONSUMIDA: " +mincons+"Kw");
System.out.println("MENOR QUANTIDAD CONSUMIDA CLASS RESUDENCIAL: "
+maxr+"Kw");
System.out.println("MENOR QUANTIDAD CONSUMIDA CLASS COMERCIAL: "
+maxc+"Kw");
System.out.println("MENOR QUANTIDAD CONSUMIDA CLASS INDUSTRIAL: "
+maxi+"Kw");
long media = qtdKw/cont;
System.out.println("MÉDIA DO CONSUMO: " +media+"Kw");
}
}
EX.14

public class MyClass {


public static void main(String args[]) {

//delcarando as variaveis

long m1= 0;
long m2= 0;
long v1 = 20;
long v2 = 30;
int v3 = 40;
int v4 = 50;
long v5 = 60;
long v6 = 70;
long v7 = 80;
long max = 30;
long min = 1;
long tnes = 0;

//inicializacao das condicoes de contorno


//calculo da distancia entre as duas cidades
m1 = Math.round(Math.random()*((max)-min+1)+min);
m2 = Math.round(Math.random()*((max)-min+1)+min);

// calculo do tempo de percurso entre os dois marcos


// com as variaveis velocidades

for (m1 = 1; m1 != m2; m1 = Math.round(Math.random()*((max)-min+1)+min)){


m2 = Math.round(Math.random()*((max)-min+1)+min);
tnes = m1 + m2 / 10;
if (tnes > 2){
System.out.println("TEMPO NECESSARIO PARA PERCORRER O PERCURSO: "
+tnes+" Hora(s)");
}

}
}
}

EX.15

public class MyClass {


public static void main(String args[]) {

double bm = 15.00;
long max = 30;
long min = 1;
long ntran = Math.round(Math.random()*(max-min+1)+min);
double bmd = 5.00;

}
}

EX.16

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis

long Ni=1;
long i=0;
long s= 0;
long exp = 0;
long nf = 0; // Candidatos do sexo masculino
long nm = 0; // Candidatos do sexo feminino
long im45 = 0; Média de homens com mais de 45 anos
long nmexp = 0; // Média de mulheres com menos de 35 e com experiencia
long mif = 99;
long max = 1000;
long min = 0;
long x = 0;

//inicializacao dos acumuladores, condicoes limites e contorno

for (x = 0; x <= 10; x += 1){


max = 1000;
min = 0;

Ni = Math.round(Math.random()*((max)-min+1)+min);
max = 90;
min = 19;

i = Math.round(Math.random()*((max)-min+1)+min);
max = 2;
min = 0;

s = Math.round(Math.random()*((max)-min+1)+min);
exp = Math.round(Math.random()*((max)-min+1)+min);
if (s > 0){
nf += 1;
if (i < 35 && exp > 0){
nmexp += 1;
if (i < mif){
mif = i;

//impressao dos resultados

System.out.println("N DA INCRICAO, Mulheres de menor idade/c.experiencia: " + Ni);


}
}
}
if (s == 0){
nm += 1;
if (i > 45){
im45 += i;
}
}
}
System.out.println("MENOR IDADE DAS M: " + mif);
System.out.println("NUMERO DE HOMENS: " + nm);
System.out.println("NUMERO DE MULHERES: " + nf);
im45 = Math.round(im45/nm);
System.out.println("MEDIA DE HOMENS COM MAIS DE 45: " + im45);
System.out.println("MULHERES COM MENOS DE 35/c.Experiencia: " + nmexp);

}
}

EX.17

public class MyClass {


public static void main(String args[]) {

//declarando as variaveis

double pi= 5.0; //Valor ingresso


double iv = 120.0; // N. de ingressos vendidos
double des = 200.0;
double dip = 0.50;

//impressão

System.out.println("VALOR DO INGRESSO: " + pi);


System.out.println("INGRESSOS VENDIDOS: " + iv);
System.out.println("LUCRO MÉDIO: " + (iv * pi));

// resolucao supondo que as despesas permanecam constantes

double x = 0;
for (x = 5.0; x >= 1.5; x -= dip){
pi -= dip;
iv += 26;

//Impressao

System.out.println("VALOR DO INGRESSO: " + pi);


System.out.println("INGRESSOS VENDIDOS: " + iv);
System.out.println("LOCRO MÉDIO: " + (iv * pi));
}
}
}

EX.18

public class MyClass {


public static void main(String args[]) {

//delcaracao das variaveis

double max = 10.0;


double min = 3.0;
double tf1 = Math.round(Math.random()*((max)-min+1)+min); //tempo padrao da etapa1
double tf2 = Math.round(Math.random()*((max)-min+1)+min); //tempo padrao da etapa2
double tf3 = Math.round(Math.random()*((max)-min+1)+min); //tempo padrao da etapa3
long ni = 0; //numero de inscricao da equipe
max = 9999;
min = 9950;
double te = 0;
double p = 0;
double vt = 0;
long eqv = 0;
double mp = 0;
long x = 0;

//inicio de cada etapa

for (x = Math.round(Math.random()*((max)-min+1)+min); x != 9999; x =


Math.round(Math.random()*((max)-min+1)+min)){
ni = Math.round(Math.random()*((max)-min+1)+min);
max = 10.0;
min = 1.00;
te = Math.round(Math.random()*((max)-min+1)+min);

//calculo de pontos obtidos pela equipe

vt = tf1 - te;
if (vt < 3.0){
p += 100;
}
else if (vt >= 3 && vt <= 5){
p += 80;
}
else if (vt > 5){
p += 80-(vt-5)/5;
}
te = Math.round(Math.random()*((max)-min+1)+min);
vt = tf2 - te;
if (vt < 3.0){
p += 100;
}
else if (vt >= 3 && vt <= 5){
p += 80;
}
else if (vt > 5){
p += 80-(vt-5)/5;
}
te = Math.round(Math.random()*((max)-min+1)+min);
vt = tf3 - te;
if (vt < 3.0){
p += 100;
}
else if (vt >= 3 && vt <= 5){
p += 80;
}
else if (vt > 5){
p += 80-(vt-5)/5;
}
if (p >= mp){
mp = p;
eqv = ni;
}
max = 9999;
min = 9950;
p = 0;
}

//impressao dos resultados

System.out.println("A equipe campea foi a equipe " + eqv);


System.out.println("Total de pontos da equipe foi: " + mp);

}
}
EX.19

public class MyClass {


public static void main(String args[]) {

//declarando as variaveis

long ne =20; //Numero de empregrados na secao


double sf= 0;
long ni= 0;
long nc = 0;
long npb = 0;
double sb = 0;
double sl = 0;
long max = 2500;
long min = 1100;

//inicializacao dos acumuladores

sf = Math.round(Math.random()*((max)-min+1)+min);
long x = 0;
for (x = 0; x <= ne; x++){

max = 9999;
min = 0001;

ni = Math.round(Math.random()*((max)-min+1)+min);

//Calculo da comissao e salario bruto

max = 45;
min = 1;
nc = Math.round(Math.random()*((max)-min+1)+min);
if (nc >= 10){
nc = 100 * nc;
}
else {
nc = 50 * nc;
}

// N de televisores preto e branco

npb = Math.round(Math.random()*((max)-min+1)+min);
if (npb >= 20){
npb = 40* npb;
}
else {
npb = 20* npb;
}
//Calcudo do INPS

sb = sf + nc + npb;
sf = sf - (sf * 8/100);
sl = sf + nc + npb;
if (sl >= 3000.00){
sl = sl - (sl * 5/100);
}
System.out.println("---Numero da inscricao – Salario Bruto/Liquido---");

System.out.println("Inscricao: " + ni);


System.out.println("Bruto: " + sb);
System.out.println("Liquido: " + sl);
}
}
}

EX.20

public class MyClass {


public static void main(String args[]) {

//declarando as variaveis

int max = 31;


int min = 1;

long dia = Math.round(Math.random()*((max)-min+1)+min);


max = 12;
max = 1;

long mes = Math.round(Math.random()*((max)-min+1)+min);


max = 2099;
min = 1900;

long ano = Math.round(Math.random()*((max)-min+1)+min);


long D = 0;
long A = 0;
long M = 0;
long S = 0;
double Ds = 0;
long x = 0;

//inicializacao dos acumuladores

for (x = 0; x <= 50; x++){

max = 31;
min = 1;
dia = Math.round(Math.random()*((max)-min+1)+min);
max = 12;
min = 1;
mes = Math.round(Math.random()*((max)-min+1)+min);
max = 2099;
min = 1900;
ano = Math.round(Math.random()*((max)-min+1)+min);
D = dia;
A = ano%100;
S = ano%10000 - ano%100;
if (mes < 3){
M = mes + 10;
}
else{
M = mes - 2;
}
Ds = ( (2.6*(M - 0.2)/1) + D + A + (A/4) + (S/4) -2 * S )% 7;

System.out.println("DIA: " + dia + "MES: " + mes + "ANO: " + ano + "Dia da semana:
"+Math.round(Ds * -1));
}
}
}

EX.21

public class MyClass {


public static void main(String args[]) {

//declarando as variaveis e seus respectivos valores


// inicializacao dos acumuladores globais

int max = 31;


int min = 1;
long nop=0;
long npf=0;
long sex=0;
double sal = 0;
double salm = 1100;
double tmen = 0;
long tpf = 0;
double mpm = 0;
double mpf = 0;
long cm = 0;
long cf = 0;
long nmsal = 0;
double msal = 0;
long x = 0;
int xmax = 1000;
int xmin = 0;

// inicializacao das condicoes de extremos


// calculo do salario do operario
// inicializacao dos acumuladores locais
// calculo do salario do operario

for (x = 1; x <= 100; x++){


max = 1000;
min = 0000;
nop = Math.round(Math.random()*((max)-min+1)+xmin);
max = 60;
min = 0;
npf = Math.round(Math.random()*((max)-min+1)+xmin);
max = 15;
min = 5;
sex = Math.round(Math.random()*((max)-min+1)+xmin);
if (sex >=10){
cm += 1;
mpm += npf;
}
else{
cf += 1;
mpf += npf;
}

if (npf <= 30){


sal = salm;
}
else if (npf >31 && npf <= 35){
sal = salm +(((salm*3)/100) *(npf - 30));
}
else if (npf >35){
sal = salm +(((salm*5)/100) *(npf - 30));
}
if (sal > msal){
msal = sal;
nmsal = nop;
}
tmen += sal;
tpf += npf;

System.out.println("SALARIO DO FUNCIONARIO: "+ sal);

}
mpm = mpm/cm;
mpf = npf/cf;
System.out.println("Folha mensal: "+tmen);
System.out.println("Total de peças por mes: "+tpf);
System.out.println("Media peças de por Homens: "+mpm);
System.out.println("Média peças de Mulhores: "+mpf);
System.out.println("Operadio com maior salario"+nmsal);
System.out.println("Salário do operário(a): "+msal);
}
}

EX.22

public class MyClass {


public static void main(String args[]) {

//Declaracao das variaveis e seus respectivos valores

double max = 1000;


double min = 100;
double lst = Math.round(Math.random()*((max)-min+1)+min);
max = 1000;
min = lst;
double lux = Math.round(Math.random()*((max)-min+1)+min);
long opst = 24;
long hdst = 1;
long oplux = 32;
long hdlux = 2;
long nop = 40;

// inicializacao dos parametros iniciais

long selector = 0;
long x = 0;
for (x = 1; x <= nop; x++){
selector = Math.round(Math.random()*((max)-min+1)+min);
if (selector >= 500){
lux += lux;
}
else {
lst += lst;
}

}
System.out.println("O lucro total é: " + Math.round(lst + lux));
}
}
EX.23

EX.24

public class MyClass {


public static void main(String args[]) {

//declarando valores

long A = 1;
long B = 1;
long S = 0;
long x = 0;

//inicializacao das condicoes eniciais


//Fazendo o calculo do somatorio

S += A/B;
for (x = A; x <= 97; x += 2){
A += 2;
B += 1;
S += A/B;
}
//impressao do resultado

System.out.println("O valor de S: " + S);


}
}

EX.25

public class MyClass {


public static void main(String args[]) {

//declarando variaveis e seus valores

long A = 2;
long fA = 1;
long B = 50;
long S = 0;
long x = 0;

//inicializacao dos acumuladores

S += Math.round(Math.pow(A, fA)/B);

//faz o calculo do somatorio

for (x = fA; x <= 49; x += 1){


fA += 1;
B -= 1;
S += Math.round(Math.pow(A, fA)/B);
}
//impressao do resultado

System.out.println("O valor de S é: " + S);


}
}

EX.26

public class MyClass {


public static void main(String args[]) {

//declarando variaveis e seus valores

long B = 37;
long R = 38;
long A = 1;
long M = B * R/A;
long x = 0;

//inicializacao das condicoes iniciais


//faz o calculo da somatorio

for (x = A; x <= 36; x += 1){


B -= 1;
R -= 1;
A += 1;
M += B * R/A;

//Impressão do resultado

System.out.println("O valor de S é: " + M);


}
}
EX.27

public class MyClass {


public static void main(String args[]) {

//Declarando variaveis e seus valores

long B = 1;
long F = 1;
long A = 1;
long E = 1;
long fE = 3;
double M = 0;
long H = 1;

//inicializacao de acumuladores e condicoes iniciais

M += (B/F * H);
long x = 0;

//faz o calculo do somatorio

for (x = F; x <= 100; x += E){


fE += 2;
A += 1;
E += fE;
B += A;
F += E;
H = H * -1;
M += (B/F) * H;
}

//impressao do resultado

System.out.println("O valor de S é: " + M);


}
}

EX.28

public class MyClass {


public static void main(String args[]) {

//Declarando variaveis e seus valores

long B = 1000;
long F = 1;
long A = 3;
long E = 1;
double M = 0;
long H = 1;

//inicializacao de acumuladores e condicoes iniciais

M += (B/F * H);
long x = 0;

//faz o calculo do somatorio

for (x = 1; x <= 50; x += 1){


B -= A;
F += E;
H = H * -1;
M += (B/F) * H;
System.out.println("M = " + M);
}

//impressao do resultado

System.out.println("O valor de S é: " + M);


}
}

EX.29

public class MyClass {


public static void main(String args[]) {

//Declarando variaveis e seus valores

long B = 480;
long F = 10;
long A = 5;
long E = 1;
double M = 0;
long H = 1;

//inicializacao dos acumuladores

M += (B/F * H);
long x = 0;

//faz o calculo do domatorio

for (x = 1; x <= 30; x += 1){


B -= A;
F += E;
H = H * -1;
M += (B/F) * H;
System.out.println("M = " + M);
}

//impressao do resultado

System.out.println("O valor de S é: " + M);


}
}

EX.30

public class MyClass {


public static void main(String args[]) {

//Declarando variaveis e seus valores

double A = 0.0; //o ângulo a ser gerado


long P = 1;
long sP = 2;
long D = 1;
double M = 0;
long H = 1;
long x = 0;
long y = 0;

//inicializacao das condicoes iniciais


//faz o calculo do somatorio

for (x = 1; x <= 63; x += 1){


D = 1;
for (y = 1; y <= P; y += 1){
D = D * y;
}

M += Math.round((Math.pow(A, P)/D) * H);


P += sP;
A += 0.1;
H = H * -1;

}
System.out.println("O valor de S é: " + M);
}
}
EX.31

public class MyClass {


public static void main(String args[]) {

//Declarando variaveis e seus valores

long A = 4;
long D = 1;
long sD = 2;
long H = 1;
double M = 0;
long x = 0;
long y = 0;

//Faz o calculo do aomatorio

for (x = 1; x <= 63; x += 1){

if (A/D >= 0.0001){


M += Math.round((A/D) * H);
}
D += sD;
H = H * -1;

}
System.out.println("O valor calculado é: " + M);
}
}

EX.42

public class MyClass {


public static void main(String args[]) {

//declaracao de variaveis e seus valores

long max = 50;


long min = 0;

//Recebendo as coordenadas

long x1 = Math.round (Math.random() * (max-min+1) + min);


System.out.println("Informe o valor de x1 "+ x1);
long y1 = Math.round (Math.random() * (max-min+1) + min);
System.out.println("Informe o valor de y1 "+ y1);

long x2 = Math.round (Math.random() * (max-min+1) + min);


System.out.println("Informe o valor de x2 "+ x2);

long y2 = Math.round (Math.random() * (max-min+1) + min);


System.out.println("Informe o valor de y2 "+ y2);

//Fazendo o calculo da distancia D

long d = 0;
long s = x1 + y1 + x2+y2;
for (s = (x1+y1+x2+y2); s != 0; s= (x1+y1+x2+y2)){
d = (x2 - x1) *2 + (y2 - y1) * 2;

//impressao do resultado

System.out.println("A distancia calculada é: "+ d);


}
}
}

EX.43

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis e seus respectivos valores

long max = 100;


long min = 0;

//Recebendo as coordenadas

long a = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de A: "+ a);

long b = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de B: "+ b);

long c = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de C: "+ c);

long d = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de D: "+ d);

long u = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de U: "+ u);
long v = Math.round(Math.random()*(max-min+1)+min);
System.out.println("Informe o valor de V: "+ v);

//calcolo da solucao X

long y = 0;
long x = 0;

y = -c*(a*d) -b*c*u+a*a*d - b*c*v;


x = (u - b*y)/a;

//imprimendo os resultados

System.out.println("O valor de x "+ x);


System.out.println("O valor de y "+ y);
}
}

EX.44

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis

long max = 100;


long min = 0;
long a = Math.round(Math.random()*(max-min+1)+min);
long b = Math.round(Math.random()*(max-min+1)+min);
long y = 0;
long ba = a - b;
long at = 0;
long s = a+b;

//Recebendo os parametros

for (s = 1; s != 0; s = (a+b)){
a = Math.round(Math.random()*(max-min+1)+min);

b = Math.round(Math.random()*(max-min+1)+min);

y = (a*Math.round(Math.random()*(max-min+1)+min)) + b;

//calculo da area do triangulo

ba = a - b;
at = (ba * y)/2;

//impressão dos resultados


System.out.println("Valor da area do triangulo : "+ at );

}
}
}

EX.45

public class MyClass {


public static void main(String args[]) {

//declaração das variaveis

long f = 0;
long x = 0;
long h = 0;
long g = 0;
long y = f + g;

for (x = 1; x<= 10; x++) {

h = (x*2) - 16; //calculo da funcao h(x)


g = (x*2) + 16; //g(x) = x^2 + 16 se f(x) = 0
if (h >= 0.1){ // f(x) = h(x) se h(x) >= 0
f = h; // f(x) = 1 se h(x) < 0
}

else if (h < 0){


g = (x*2) + 16;
}

y = f + g; //calculo de Y

//Impressão de resultados

System.out.println("Valor de Y : "+ y );
System.out.println("Valor de F : "+ f );
System.out.println("Valor de G : "+ g );
System.out.println("Valor de H : "+ h );

}
}
}
EX.46

public class MyClass {


public static void main(String args[]) {

double y;

double x;

x = 1;

y = 1;

x = STDIN_SCANNER.nextDouble();

y = STDIN_SCANNER.nextDouble();

if(y < 3 * x && y > x / 3) {

System.out.println("INTERIOR");

} else {

System.out.println("INTERIOR");

} else if(x < 0) {

if(y > 3 * x && y < x / 3) {

System.out.println("EXTERIOR");

} else {

System.out.println("EXTERIOR");

public final static Scanner STDIN_SCANNER = new Scanner(System.in);

}
EX.47

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis

long A = 0; //o limite inferior dos numeros


long B = 0; //o limite superior dos numeros
long max = 100;
long min = 1;
B = Math.round(Math.random()*(max-min+1)+min);

//inicializacao dos acumuladores

max = B -1;

//lendo os limites da sequencia de numeros

A = Math.round(Math.random()*(max-min+1)+min);
long S = (A+B) * ((A+B)*(A+B));

//resultados

System.out.println("A soma dos cubos dos pares é: "+ S);


}
}

EX.48

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis

double V = 0 //o volume calculado


double r = 0; //o raio

double pi = Math.PI;

for (r = 0.5; r <= 20; r += 0.5){


V = (4/3)*pi*(r*r*r);

//resultados

System.out.println("Volume da esfera é: "+ V);


}
}
}
EX.49

public class MyClass {


public static void main(String args[]) {

//declaracao das variaveis

long npoligonos = 0; //o numero de poligonos


long area = 0; //area do poligono regular escrito
long N = 0; //o numero de lados do poligono
long R = 0; //o raio da circunferencia

long max = 100;


long min = 0;

//calcula a area dos poligonos inscritos

for (npoligonos = 1; npoligonos <= 10; npoligonos += 1){

N = Math.round(Math.random()*((max)-min+1)+min);
R = Math.round(Math.random()*((max)-min+1)+min);

//calcula a area

area = (R/2) * N;

//resultado

System.out.println("A area calculada é : "+ area);


}
}
}

EX.50

public class MyClass {


public static void main(String args[]) {

//declaraçao das variaveis

long nlados=5; //medida do perimetro


long perimetro = 0; //o numero de lados do poligono
long semi = 0

//inicializacao das condicoes iniciais


//calculo do perimetro

for (nlados = 5; nlados <= 100; nlados += 5){


semi = nlados/2
//resultados

System.out.println("O semi perimetro é : " + semi);


}
}
}

Você também pode gostar