fork download
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package projeto_interface_básica;
  6.  
  7. import java.util.Scanner;
  8. import javax.swing.JOptionPane;
  9.  
  10. /**
  11.  *
  12.  * @author ALLAN
  13.  */
  14. public class Projeto_interface_básica {
  15.  
  16. /**
  17.   * @param args the command line arguments
  18.   */
  19. public static void main(String[] args) {
  20. // TODO code application logic here
  21.  
  22. int n,q,x,v;
  23.  
  24. q=1;
  25.  
  26.  
  27. n= Integer.parseInt(JOptionPane.showInputDialog("Digite a quantidade TOTAL de carros: "));
  28.  
  29.  
  30. String A[] = new String [n];
  31. String B[] = new String [n];
  32. String C[] = new String [n];
  33. leitura(n,A,B,C);
  34.  
  35.  
  36. while(q==1){
  37.  
  38. v=1;
  39. while(v==1){
  40.  
  41.  
  42.  
  43. x= Integer.parseInt(JOptionPane.showInputDialog("Digite o número de uma das opções a baixo: "+"\n1.LOCAÇÃO \n2.DEVOLUÇÃO \n3.Verificação de um automóvel \n4.Verificação de todos os automóveis \n5.AJUDA \n6.SAIR"));
  44.  
  45. if(x<1 | x>6){
  46. v=1;
  47. }
  48. else{
  49. if(x==1){
  50. locação(n,A,B,C);
  51. v=0;
  52. }
  53. if(x==2){
  54. devolução(n,A,B,C);
  55. v=0;
  56. }
  57. if(x==3){
  58. verificaçãoPontual(n,A,B,C);
  59. v=0;
  60. }
  61. if(x==4){
  62. verificaçãoGERAL(n,A,B,C);
  63. v=0;
  64. }
  65. if(x==5){
  66. JOptionPane.showMessageDialog(null,"Texto de ajuda");
  67. }
  68. if(x==6){
  69. q=0;
  70. v=0;
  71. }
  72.  
  73. }
  74.  
  75. }
  76.  
  77. }
  78. }
  79.  
  80.  
  81. public static void leitura (int k, String [] X,String []Y, String []W){
  82.  
  83. int i;
  84.  
  85. i=0;
  86.  
  87. while(i<k){
  88. X[i] = "GARAGEM";
  89. Y[i] = " ";
  90. W[i] = " ";
  91. i++;
  92. }
  93.  
  94. }
  95.  
  96. public static void locação (int m,String [] G,String [] H, String []J){
  97. Scanner ent = new Scanner (System.in);
  98. int u,s;
  99. s=1;
  100.  
  101.  
  102. while(s==1){
  103.  
  104. u= Integer.parseInt(JOptionPane.showInputDialog("Digite a posição do carro (1 à "+m+") que deseja locar: "));
  105.  
  106. if((u-1)<0 | (u-1)>=m){
  107. s=1;
  108. }
  109. else{
  110.  
  111. H[u-1] = JOptionPane.showInputDialog("Digite o nome do cliente: ");
  112.  
  113. J[u-1] = JOptionPane.showInputDialog("Digite o número do documento do cliente: ");
  114. G[u-1] = "LOCADO";
  115. JOptionPane.showMessageDialog(null,"O automóvel número "+1+" foi alugado.");
  116. s=0;
  117. }
  118. }
  119.  
  120. }
  121.  
  122. public static void devolução (int m,String [] G,String [] H, String []J){
  123. Scanner ent = new Scanner (System.in);
  124. int u,s;
  125. s=1;
  126.  
  127.  
  128. while(s==1){
  129.  
  130. u= Integer.parseInt(JOptionPane.showInputDialog("Digite a posição do carro (1 à "+m+") que deseja locar: "));
  131.  
  132. if((u-1)<0 | (u-1)>=m){
  133. s=1;
  134. }
  135. else{
  136.  
  137. H[u-1] = " ";
  138. J[u-1] = " ";
  139. G[u-1] = "GARAGEM";
  140. JOptionPane.showMessageDialog(null,"O automóvel número "+u+" foi devolvido.");
  141. s=0;
  142. }
  143. }
  144. }
  145.  
  146. public static void verificaçãoGERAL (int m,String [] G,String [] H, String []J){
  147. Scanner ent = new Scanner (System.in);
  148. int i;
  149. i=0;
  150.  
  151. while(i<m){
  152. JOptionPane.showMessageDialog(null,(i+1)+" "+G[i]+" "+H[i]+" "+J[i]);
  153. i++;
  154. }
  155.  
  156. }
  157.  
  158. public static void verificaçãoPontual (int m,String [] G,String [] H, String []J){
  159. Scanner ent = new Scanner (System.in);
  160. int u,s;
  161. s=1;
  162.  
  163.  
  164. while(s==1){
  165.  
  166. u= Integer.parseInt(JOptionPane.showInputDialog("Digite a posição do carro (1 à "+m+") que deseja verificar: "));
  167.  
  168. if((u-1)<0 | (u-1)>=m){
  169. s=1;
  170. }
  171. else{
  172.  
  173. JOptionPane.showMessageDialog(null,(u)+" "+G[u-1]+" "+H[u-1]+" "+J[u-1]);
  174.  
  175. s=0;
  176. }
  177. }
  178.  
  179.  
  180.  
  181. }
  182. }
Runtime error #stdin #stdout 0.29s 213824KB
stdin
Standard input is empty
stdout
Standard output is empty