-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy path010.cs
29 lines (22 loc) · 847 Bytes
/
010.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
// crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos dólares ela pode comprar
using System;
static 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() {
double valor = int.Parse(io.input("Digite o valor em real: R$"));
double cotacaoDolar = 5.21;
// aparentemente divisão só funciona com double
// essa gambiarra formata o valor com dois digitos depois da virgula
double dolarObtido = Math.Truncate((valor / cotacaoDolar * 100)) / 100;
io.print($"Você pode comprar ${dolarObtido}");
}
}