fork download
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. int[] codigoAluno = new int[10];
  6. string[] nomeAluno = new string[10];
  7. double[] nota1 = new double[10];
  8. double[] nota2 = new double[10];
  9. double[] nota3 = new double[10];
  10. int opcao;
  11. do
  12. {
  13. Console.WriteLine("[ 1 ] Matricular aluno");
  14. Console.WriteLine("[ 2 ] Cancelar matrícula de um aluno");
  15. Console.WriteLine("[ 9 ] Relatório de alunos cadastrados");
  16. Console.WriteLine("[ 0 ] Sair do Software");
  17. Console.WriteLine("-------------------------------------");
  18. Console.Write("Digite uma opção: ");
  19. opcao = Int32.Parse(Console.ReadLine());
  20. switch (opcao)
  21. {
  22. case 1:
  23. matriculaAluno(ref codigoAluno, ref nomeAluno);
  24. break;
  25. case 2:
  26. cancelarAluno(ref codigoAluno, ref nomeAluno);
  27. break;
  28. case 9:
  29. relatorioAlunos(ref codigoAluno, ref nomeAluno);
  30. break;
  31. default:
  32. saiPrograma();
  33. break;
  34. }
  35. Console.ReadKey();
  36. Console.Clear();
  37. }
  38. while (opcao != 0);
  39. }
  40.  
  41. private static void relatorioAlunos(ref int[] codigoAluno, ref string[] nomeAluno)
  42. {
  43. Console.Clear();
  44. Console.WriteLine("----------------------------------------------------------------");
  45. Console.WriteLine("***************| RELATORIO DE ALUNOS |**************************");
  46. Console.WriteLine("----------------------------------------------------------------");
  47. Console.WriteLine("-------Codigo--------Aluno--------------------------------------");
  48. for (int i = 0; i < 10; i++)
  49. {
  50. Console.WriteLine(" {0} {1}",codigoAluno[i],nomeAluno[i]);
  51. }
  52. Console.WriteLine("----------------------------fim relatório----------------------");
  53. }
  54.  
  55. private static void cancelarAluno(ref int[] codigoAluno, ref string[] nomeAluno)
  56. {
  57. Console.Clear();
  58. int i;
  59. Console.WriteLine("----------------------------------------------------------------");
  60. Console.WriteLine("***************| CANCELAMENTO DE MATRÍCULA |********************");
  61. Console.WriteLine("----------------------------------------------------------------");
  62. Console.Write("Digite a posicao/MATRICULA do vetor que deseja CANCELAR: ");
  63. i = Int32.Parse(Console.ReadLine());
  64. codigoAluno[i] = 0;
  65. nomeAluno[i] = "";
  66. Console.WriteLine("Aluno CANCELADO com Sucesso !");
  67. }
  68.  
  69. private static void saiPrograma()
  70. {
  71. Console.WriteLine();
  72. Console.WriteLine("Bye Bye, vc saiu do Programa. Clique qq tecla para sair...");
  73. }
  74.  
  75. private static void matriculaAluno(ref int[] codigoAluno, ref string[] nomeAluno)
  76. {
  77. Console.Clear();
  78. bool jaExiste = false;
  79. bool codigoEstaNoIntervalo;
  80. int i = 0;
  81. do
  82. {
  83. jaExiste = false;
  84. Console.WriteLine("----------------------------------------------------------------");
  85. Console.WriteLine("******************| MATRÍCULA DE ALUNOS |***********************");
  86. Console.WriteLine("----------------------------------------------------------------");
  87. Console.Write("Digite a posicao do vetor que deseja cadastrar: ");
  88. i = Int32.Parse(Console.ReadLine());
  89. Console.Write("Código do aluno na Posição {0}: ", i);
  90. codigoAluno[i] = Int32.Parse(Console.ReadLine());
  91. codigoEstaNoIntervalo = verificaCodigoIntervalo(codigoAluno[i]);
  92. jaExiste = verificaCodigoJaExiste(codigoAluno[i], i, codigoAluno);
  93.  
  94. if (jaExiste == false)
  95. {
  96. if (codigoEstaNoIntervalo == false)
  97. {
  98. Console.WriteLine("O Código do aluno deve ser entre 1 e 1000!");
  99. Console.ReadKey();
  100. Console.Clear();
  101. }
  102. else
  103. {
  104. Console.Write("Nome do aluno na Posição {0}: ", i);
  105. nomeAluno[i] = Console.ReadLine();
  106. }
  107. }
  108. else
  109. {
  110. Console.WriteLine("O Código do aluno {0} já existe!", codigoAluno[i]);
  111. codigoAluno[i] = 50000;
  112. Console.ReadKey();
  113. Console.Clear();
  114. }
  115. }
  116. while (codigoAluno[i] < 1 || codigoAluno[i] > 1000);
  117. Console.WriteLine("Aluno cadastrado com Sucesso !");
  118. }
  119.  
  120. private static bool verificaCodigoJaExiste(int codigoDigitado, int posicaoCodigoDigitado, int[] vetor)
  121. {
  122. bool jaExiste = false;
  123. for (int i = 0; i < vetor.Length; i++)
  124. {
  125. if (vetor[i] == codigoDigitado && i != posicaoCodigoDigitado)
  126. {
  127. jaExiste = true;
  128. }
  129. }
  130. return jaExiste;
  131. }
  132.  
  133. private static bool verificaCodigoIntervalo(int codigo)
  134. {
  135. bool estaNoIntervalo = false;
  136. if (codigo > 0 && codigo <= 1000)
  137. estaNoIntervalo = true;
  138. else
  139. estaNoIntervalo = false;
  140.  
  141. return estaNoIntervalo;
  142. }
  143. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(13,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(14,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(15,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(16,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(17,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(18,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(19,25): error CS0103: The name `Int32' does not exist in the current context
prog.cs(35,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(36,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(43,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(44,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(45,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(46,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(47,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(50,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(52,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(57,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(59,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(60,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(61,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(62,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(63,17): error CS0103: The name `Int32' does not exist in the current context
prog.cs(66,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(71,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(72,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(77,13): error CS0103: The name `Console' does not exist in the current context
prog.cs(84,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(85,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(86,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(87,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(88,21): error CS0103: The name `Int32' does not exist in the current context
prog.cs(89,17): error CS0103: The name `Console' does not exist in the current context
prog.cs(90,34): error CS0103: The name `Int32' does not exist in the current context
prog.cs(98,25): error CS0103: The name `Console' does not exist in the current context
prog.cs(99,25): error CS0103: The name `Console' does not exist in the current context
prog.cs(100,25): error CS0103: The name `Console' does not exist in the current context
prog.cs(104,25): error CS0103: The name `Console' does not exist in the current context
prog.cs(105,40): error CS0103: The name `Console' does not exist in the current context
prog.cs(110,21): error CS0103: The name `Console' does not exist in the current context
prog.cs(112,21): error CS0103: The name `Console' does not exist in the current context
prog.cs(113,21): error CS0103: The name `Console' does not exist in the current context
prog.cs(117,13): error CS0103: The name `Console' does not exist in the current context
Compilation failed: 42 error(s), 0 warnings
stdout
Standard output is empty