CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Java and JSP (http://www.codingforums.com/forumdisplay.php?f=54)
-   -   why i cant delete and to see my overview.! (http://www.codingforums.com/showthread.php?t=275917)

zertfs 10-09-2012 03:41 PM

why i cant delete and to see my overview.!
 
PHP Code:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author FritzEam
 */

    
import java.util.*;

public class 
Dubg {
public static 
Scanner input = new Scanner(System.in);
public static 
int[] code = new int[10];
public static 
String[] name = new String[30];
public static 
int[] qty = new int[10];
public static 
double[] price = new double[10];

public static 
int[] pcode = {11121122113311441155};
public static 
String[] pname = {"Comics""Horror Book""Novel""Nature""Magazine"};
public static 
int[] nqty = {101515510};
public static 
double[] nprice = {49.9979.9959.99109.9959.99};

public static 
int jsrp 0mnnumnwqty=0trans=0;

public static 
double total 0tot 0change 0nwprice=0;
public static 
boolean c false;
    


public static 
void main(String[] args){

CountItems();
for ( 
int z 05z++ ) {
code[z] = pcode[z];
name[z] = pname[z];
qty[z] = nqty[z];
price[z] = nprice[z];
}    

while(
) {
System.out.println("\n1. ADD ITEMS ");
System.out.println("2. VIEW ITEMS ");
System.out.println("3. SEARCH ITEMS ");
System.out.println("4. MODIFY ITEMS ");
System.out.println("5. DELETE ITEMS ");
System.out.println("6. PROCESS TRANSACTION ");
System.out.println("7. SALES OVERVIEW ");
System.out.println("8. EXIT ");

System.out.print("Enter number of your choice: ");
input.nextInt();

System.out.println();

switch(
j) {

case 
1System.out.println("---ADD RECORDS---"); add(); break;
case 
2System.out.println("---VIEW RECORDS---"); view(); break;
case 
3System.out.println("---SEARCH RECORDS---"); search(); break;
case 
4System.out.println("---MODIFY RECORDS---"); modify(); break;
case 
5System.out.println("---DELETE---"); delete(); break;
case 
6System.out.println("---PROCESS TRANSACTION---"); transaction(); break;
case 
7System.out.println("---SALES OVERVIEW---"); overview(); break;
case 
8System.out.println("END APPLICATION"); break;
}
}    
}

public static 
void CountItems() {
srp=0;

for ( 
int z 010z++ ) {
if ( !(
name[z] == null)) {
srp++;
}
}
}

public static 
void add(){
CountItems();
/*System.out.print("Enter number of data to be entered: ");
num = input.nextInt();

for(int a = 0; a < num; a++) {*/

System.out.print(" Enter Product Code: "); code[srp] = input.nextInt();    
System.out.print(" Enter Product Name: "); name[srp] = input.next();    
System.out.print(" Enter Quantity: "); qty[srp] = input.nextInt();    
System.out.print(" Enter Price: "); price[srp] = input.nextInt();    

}    
//}

public static void view(){
CountItems();
for(
int i 0srpi++) {
System.out.println("\n Product Code: " code[i] + " \n Product Name: " name[i] + 
"\n Quantity: " qty[i] + "\n Price: " price[i]); 
}    
}

public static 
void search(){
System.out.print("Enter Product Code: ");
int search input.nextInt();    

for(
int a 0srpa++) { 
if(
search == (code[a])) 
{
System.out.println("\n Product Code: " code[a] + " \n Product Name: " name[a] + "\n Quantity: " qty[a] + 
"\n Price: " price[a]);
true;
}
}
if(
== falseSystem.out.println("NO BOOK FOUND!"); 
}

public static 
void modify(){
System.out.print("\nEnter Product Code: ");
int mod input.nextInt();

for (
int a 0srpa++ ) {
if ( 
mod == (code[a])) {
System.out.print("\nEnter a new Product Name : "); name[a] = input.next();
System.out.print("Enter a new Price : "); price[a] = input.nextInt();

System.out.println("SAVE CHANGES!!!");
true;
}
}
if ( 
== false System.out.println("CANNOT BE FOUND!");
}

public static 
void delete(){

String s" "unknown" " 

System.out.print("\nEnter Product Name: "); s=input.next();


for(
int a 010a++){
if(
s.equalsIgnoreCase(name[a])){
code[a] = 0;
name[a] = unknown;
price[a] = 0.0;
qty[a] =  ;

System.out.println("ITEM DELETED!!!");
true;
}
}
if(
== false)
System.out.println("CANNOT BE FOUND!");
}

public static 
void transaction(){
System.out.print("\nEnter No. of Items to Buy: ");
trans input.nextInt();

for(
int a 0transa++) {
System.out.print("Enter code "+(a+1)+": "); input.nextInt();
System.out.print("Enter quantity: "); input.nextInt();

for (
int i 0srpi++) {
if ( 
== code[i] ) {
total += (price[i] * n);
}
}    
}

System.out.println("\nTotal Payable: ""Php" total);

System.out.print("Enter cash: ");
int mon input.nextInt();

change mon total;

if(
mon>=total)
System.out.println("Change: " "Php" change);
else
System.out.println("YOUR MONEY IS NOT ENOUGH!!!");
}

public static 
void overview(){

for (
int i 0srpi++) {

nwqty qty[i] - n;
nwprice price[i] * qty[i];


System.out.print("\n\nProduct Code: " code[i]);
System.out.print("\nProduct Name: " name[i]);
System.out.print("\nQuantity: " nwqty);
System.out.println("\nTotal Price: " nwprice);
}
}




All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.