Skip to content

Instantly share code, notes, and snippets.

@jimywork
Created September 12, 2017 18:06
Show Gist options
  • Save jimywork/692d5a34e433ac17e70058d5a1ced192 to your computer and use it in GitHub Desktop.
Save jimywork/692d5a34e433ac17e70058d5a1ced192 to your computer and use it in GitHub Desktop.
Lista de Exercícios Java
import java.util.Scanner;
class Main {
public static void main(String[] args) {
double monthlySalary = 400;
double unitaryValue[] = new double[10];
int amountSold[] = new int[10];
int max = amountSold[0];
int pos = 0;
Scanner scanner = new Scanner(System.in);
double total = 0;
double comissao = 0;
for(int i = 1; i < 10; i++) {
System.out.printf("Digite o valor unitario do objeto %d: ", i);
unitaryValue[i] = scanner.nextDouble();
System.out.printf("Digite a quantidade vendida do objeto %d: ", i);
amountSold[i] = scanner.nextInt();
total += unitaryValue[i] * amountSold[i];
comissao = total * 0.05;
if(amountSold[i] > max) {
max = amountSold[i];
pos = i;
}
}
for(int i = 1; i < 10; i++) {
System.out.printf("\nQuantidade vendida do objeto %d:\n", i);
System.out.printf("$%2.2f x %d", unitaryValue[i], amountSold[i], total);
}
System.out.printf("\nValor geral das vendas $%2.2f", total);
System.out.printf("\nValor da comissão que será paga ao vendedor $%2.2f", comissao);
System.out.printf("\nO objeto %d foi vendido %d vezes e sua posicão no vetor %d\n", pos, max, pos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment