-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path029.cs
40 lines (31 loc) · 914 Bytes
/
029.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Desafio 029
Problema: Escreva um programa que leia a velocidade de um carro.
Se ele ultrapassar 80Km/h, mostre uma mensagem dizendo
que ele foi multado. A multa vai custar R$7,00 por cada
Km acima do limite.
Resolução do problema:
*/
using System;
class io {
public static string input(string text) {
Console.Write(text);
return Console.ReadLine();
}
public static void print(object data, string end="\n") {
string text = data.ToString();
Console.Write($"{text}{end}");
}
}
class Program {
public static void Main () {
float velocidade = float.Parse(io.input(
"Informe a velocidade do carro: "
));
if (velocidade > 80) {
float multa = (velocidade - 80) * 7;
float fixedMulta = (float) Math.Truncate(multa * 100) / 100;
io.print($"Você foi multado em R${fixedMulta}");
}
}
}