Advertisement
Fakhru

Untitled

Jul 16th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package asdasdzxc;
  7.  
  8. /**
  9. *
  10. * @author MPA3
  11. */
  12. import java.util.Scanner;
  13. public class Asdasdzxc {
  14.  
  15. static Scanner input = new Scanner(System.in);
  16. static int[] item = new int[10];
  17. static double[] price = new double[10];
  18. static int code;
  19. static int cont;
  20. public static void main(String[] args) {
  21. /*Scanner input = new Scanner(System.in);
  22. int[] item = new int[10];
  23. int code;
  24.  
  25. * */
  26.  
  27.  
  28. itemdata();
  29. searchdata();
  30.  
  31.  
  32.  
  33.  
  34. }
  35.  
  36. static void itemdata(){
  37. System.out.println("Input item code..");
  38. for(int i = 0; i<item.length;i++){
  39. System.out.print("Item Code["+(i+1)+"]:");
  40. item[i] = input.nextInt();
  41. System.out.print("Item Price["+(i+1)+"]:");
  42. price[i] = input.nextDouble();
  43.  
  44. }
  45. }
  46.  
  47. static void searchdata(){
  48. do{
  49. System.out.println("Enter An Item Code: ");
  50. code = input.nextInt();
  51. int i = 0;
  52. int truez;
  53. while( i < item.length){
  54.  
  55. if(code == item[i]){
  56. System.out.println("Item Code: "+item[i]+"\nItem Price: "+price[i]);
  57. break;
  58. }else if(i == (item.length-1)){
  59. System.out.println("Invalid Code");
  60. break;
  61. }
  62. i++;
  63. }
  64.  
  65. System.out.println("Continue? [1/2]");
  66. cont = input.nextInt();
  67. }while(cont == 1);
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement