]> web.ist.utl.pt Git - iaed.git/commitdiff
Added input
authorPedro Adão <pedro@Yogi.lan>
Thu, 25 Feb 2016 00:19:13 +0000 (00:19 +0000)
committerPedro Adão <pedro@Yogi.lan>
Thu, 25 Feb 2016 00:19:13 +0000 (00:19 +0000)
Removed non-needed brackets
Fixed format

aula02/a.out [new file with mode: 0755]
aula02/ex8.c

diff --git a/aula02/a.out b/aula02/a.out
new file mode 100755 (executable)
index 0000000..46780dc
Binary files /dev/null and b/aula02/a.out differ
index 47374c09cecfdf31a7a1f8feb0c6338a118eaf0a..ec8724c668d6d598cb57db452334c4ed8f0a8d36 100644 (file)
@@ -5,31 +5,39 @@ int insurance(int current, int age, int nAcc);
 
 int main() 
 {
-    /* ler o valor actual, a idade e o número de acidentes */
+       int c, a, nac;
 
+    printf("Valor Actual: ");
+    scanf("%d", &c);
+    printf("Idade do condutor: ");
+    scanf("%d", &a);
+    printf("Numero de Acidentes: ");
+    scanf("%d", &nac);
+
+    printf("Custo da Proxima Anuidade: %d\n",
+           insurance(c, a, nac));
+
+    return 0;
 }
 
+
 int insurance(int current, int age, int nAcc)
 {
        if(age < 25)
-    { /* confirme se precisamos mesmo destes parentesis curvos... */
                if(nAcc == 0) return 0.85 * current;
                else if(nAcc == 1) return 1.05 * current;
                else if(nAcc <= 4) return 1.5 * current;
                else 
         {
-                       printf("REFUSED");
+                       printf("REFUSED\n");
                        return 0;
                }
-       }
     else
-    {
                if(nAcc == 0) return 0.8 * current;
                else if(nAcc == 1) return current;
                else if(nAcc <= 4) return 1.3 * current;
                else {
-                       printf("REFUSED");
+                       printf("REFUSED\n");
                        return 0;
                }       
-    }
 }