Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package asdasdzxc;
- /**
- *
- * @author MPA3
- */
- import java.util.Scanner;
- public class Asdasdzxc {
- static Scanner input = new Scanner(System.in);
- static int[] item = new int[10];
- static double[] price = new double[10];
- static int code;
- static int cont;
- public static void main(String[] args) {
- /*Scanner input = new Scanner(System.in);
- int[] item = new int[10];
- int code;
- * */
- itemdata();
- searchdata();
- }
- static void itemdata(){
- System.out.println("Input item code..");
- for(int i = 0; i<item.length;i++){
- System.out.print("Item Code["+(i+1)+"]:");
- item[i] = input.nextInt();
- System.out.print("Item Price["+(i+1)+"]:");
- price[i] = input.nextDouble();
- }
- }
- static void searchdata(){
- do{
- System.out.println("Enter An Item Code: ");
- code = input.nextInt();
- int i = 0;
- int truez;
- while( i < item.length){
- if(code == item[i]){
- System.out.println("Item Code: "+item[i]+"\nItem Price: "+price[i]);
- break;
- }else if(i == (item.length-1)){
- System.out.println("Invalid Code");
- break;
- }
- i++;
- }
- System.out.println("Continue? [1/2]");
- cont = input.nextInt();
- }while(cont == 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement