fork download
  1. using static System.Console;
  2. using System;
  3.  
  4. namespace Projeto {
  5. public class Program {
  6. public static void Main() {
  7. Conta conta = new Conta();
  8. Write("Entre com o numero da conta: ");
  9. if (!int.TryParse(ReadLine(), out var numero)) return;
  10. conta.Numero = numero;
  11. WriteLine();
  12. Write("Entre com o nome: ");
  13. conta.Nome = ReadLine();
  14. WriteLine();
  15. Write("Haverá um deposito inicial (s/n)? : ");
  16. var temDeposito = ReadLine();
  17. var valor = 0M;
  18. if (temDeposito.Equals("S", StringComparison.CurrentCultureIgnoreCase)) {
  19. Write("Entre com o valor depositado: ");
  20. if (!decimal.TryParse(ReadLine(), out valor)) return;
  21. }
  22. conta.Saldo = valor;
  23. }
  24. }
  25.  
  26. public class Conta {
  27. public int Numero { get; set; }
  28. public string Nome { get; set; }
  29. public decimal Saldo { get; set; }
  30. }
  31. }
  32.  
  33. //https://pt.stackoverflow.com/q/467288/101
Success #stdin #stdout 0.02s 17228KB
stdin
1
joao
10
stdout
Entre com o numero da conta: 
Entre com o nome: 
Haverá um deposito inicial (s/n)? :