Prévia do material em texto
Rio, 07/10/2014 Correção AV1 1ª Q. public class PrimeiraQuestao { public static void main (String [] args){ int a, b, c; if (a > (b+c)) { System.out.println (“~~~~~”); System.out.println (“=====”); } else if (! (b>c)){ if ((c==a) || (b>=a)) { System.out.println (“%%%%%”); } else { System.out.println (“^^^^^”); } } else { System.out.println (“+++++”); } System.out.println (“*****”); } } a=10 ; b=5 ; c=8 ^^^^^ ***** a=10 ; b=8 ; c=5 +++++ ***** a=10 ; b=10 ; c=15 %%%%% ***** 2ª Q. Tipo Descrição Rendimento 1 Poupança 3% 2 Fundo de renda fixa 4% Ler: Tipo // Valor Calcular e mostrar o valor corrigido. Obs.: Usar a estrutura switch … case import java.util.scanner; public class SegundaQuestão { public static void main (String args []) { Scanner ent = new Scanner (System.in); float valor, novo valor ; int tipo; Systeam.out.println (“informe o tipo de investimento e o valor investido:”); tipo = ent.nextInt (); valor = ent.nextFloat(); switch (tipo) { case 1: novovalor = valor*1,03; break; case 2: novovalor = valor*1,04; break; default; System.out.println (“tipo invalido”); } System.out.println (“valor corrigido:” + novovalor); } } 3ª Q. public class TerceiraQuestao { public static void main (String args []) { int s=0 , i; for (i=1 ; i<=15 ; i+=2) { if (i>10) { System.out.printf (“%d”, i); } else { System.out.printf (“@”); } S += i } System.out.println(); System.out.println(s); } } i S Saídas obtidas 1 0 @@@@@ 11 13 15 1+2=3 0+1=1 64 3+2=5 1+3=4 5+2=7 4+5=9 7+2=9 9+7=16 9+2=11 16+9=25 11+2=13 25+11=36 13+2=15 36+13=49 15+2=17 49+15=64 B. int s=0, i=1; While (i<=15) { if (i>10) { System.out.printf (“%d”, i); } else { System.out.printf (“@”); } s+=i; i+=2; } System.out.println(); System.out.println(s); } }