Good evening all. I have what i think is a simple problem. I created this program to get info from the user and store it into an array. ( i am very new at this so if there is a better way please feel free to elaborate) . basically i am having problems with implementing my subclass. the program that i have is as follows:

(fyi.. the program is an inventory app for school using fudge . yummm)

main java file titled: mainfudge.java

*  This applicaion is an Inventory Program that can handle multiple items. Using an array
to store the items the output displays the information one product at a time,
including the item number, the name of the product, the number of units in stock, the
price of each unit, and the value of the inventory of that product. In addition, the output sorts 
the arrays and display's the value of the entire inventory as you entered it. */



import java.util.Scanner; // scanner in
import static java.lang.System.in; // cool api I found to reduce code
import static java.lang.System.out; // cool api I found to reduce code

class mainfudge {
           
public static void main(String[] args) { // here we go!
   fudgei myfudgei = new fudgei (); // Create a "link" between java files
   Scanner myScanner = new Scanner(System.in);// create a Myscanner to obtain input in command window
   
   double TempPrice;  // Intilizations
   double TotalPrice=0;
   int Num = 0;
   int LoopNum = 1 ;
   int ArrayNum=0;
   int ALength = 0;
   String[] FstringArray = new String [100]; // array for name of fudge
   double [] FOnumArray = new double [100]; // array for fudge order num
   double [] FInvArray = new double [100]; // array for inventory amount
   double [] FpriceArray = new double [100]; // array for unit price
   boolean yesno;
   int comparetype;
   int userchoice;
   
   out.println("Welcome to the Easy Fudge Inventory Application!\n" +
           "How many kinds of fudge will we be making today (max 100)?");
   LoopNum = myScanner.nextInt(); // get value for repeatagin and arraylength
   ALength = LoopNum ;
   
    for ( int counter = 1; counter <= ALength; counter++ ){ //while loop to imput info
       
            out.println("Please enter Type of Fudge: ");
            myfudgei.FudgeType = myScanner.next();
            FstringArray[ArrayNum] = myfudgei.FudgeType; // stores info into the array
                                  
            out.print("Please enter the Order Number for '");
            out.print(myfudgei.FudgeType);
            out.println("':");
            myfudgei.FudgeOrderNum = myScanner.nextDouble();
            FOnumArray[ArrayNum] = myfudgei.FudgeOrderNum; // stores info into the array
        
            out.println("Please enter the Total Number or Peices On Hand: ");
            myfudgei.FudgeInvCount = myScanner.nextDouble();
            FInvArray[ArrayNum] = myfudgei.FudgeInvCount; // stores info into the array
        
            out.println("Please enter the Price for One Peice:");
            myfudgei.FPrice = myScanner.nextDouble();
            FpriceArray [ArrayNum] = myfudgei.FPrice; // stores info into the array
                   
            TempPrice = myfudgei.FPrice * myfudgei.FudgeInvCount; // get inventory price for this type
        
            TotalPrice = TempPrice + TotalPrice ; // total inventory price adds the total
                                                  //up as the program progresses.
            
        
            out.println("Thank you\n");
            ArrayNum++; // gives values to the array position
                    }  
     
  out.println("\nWhat would you like to do now?");
  out.println("1. Display whats on hand again\n2. Edit Something\n3. Add Icing\n" +
          "4. Display Total Inventory Value\n5. Quit ");
  userchoice = myScanner.nextInt();
  
  if (userchoice == 1){
     
      while (LoopNum>0){ // sorts the results into sequential files anf places them on different lines
       
        out.print("For the ");
        out.print(mainfudge.FstringArray[Num]);
        out.print(" fudge (order number ");
        out.print(mainfudge.FOnumArray[Num]);
        out.print("), we have ");
        out.print(mainfudge.FInvArray[Num] );      
        out.print(" on hand. The price for each peice is ");
        out.print(mainfudge.FpriceArray[Num]);
        out.println(". ");
       
   
   LoopNum--; // while there us still a array value left this counts down
   Num++; // array value
        }
  }
  if (userchoice == 2){
      out.println("this function not yet availiable");
  }
  if (userchoice == 3){
      icedfudge.addicing(add5percent);
  }
  if (userchoice == 4){
       out.print(" Total value for all fudge: "); // total value of all fudge
        out.println(TotalPrice);
  }
  if (userchoice == 5){
      out.println("Thank you for using this app!");    
    }   
           
          
  }}

a fudge object. (just to hold info)

class fudgei {

        String FudgeType; // type of fudge (cholate, peanutbutter, etc.)
        double FudgeOrderNum ; // order number for customers. 
        double FudgeInvCount; // amount of peices of fudge on hand
        double FPrice ; // base price of the fudge

additional subclass(i think) in file entitled: icedfudge

class icedfudge extends fudgei
{
    double fudgeInventoryCount; // amount of peices of fudge on hand
    double fudgePrice ; // base price of the fudge
    double add5percent;
    String typeF;

    static int addicing() {
        get.fudgePrice;
        add5percent = fudgePrice*.05;
        return add5percent;
        
    }
    
    
}

okay.. if you read all of that i thank you.

the problem i am having is in the call to the subclass. at the end of my main method i have a menu that allows the user to select an additional option after filling the array (i know i could have used arraylist for this, i am still learning and prefer to keep things straightforward). the #3 option does not work because i have something screwed up. its SUPPOSED to call the method in the subclass that adds 5% to the fudge price and gives the new additional property of being "iced".

i know the code is incomplete in relation to giving the property to "fudge" but a bunp in the right direction will greatly help. (also if anyone knows someone whos brain i can pick over the phone or online (chat room) on a real time basis i have some pretty stupid questions to ask. )
again sorry for the length, any input helps!

I improved the program vastly (i think) but i am still having a problem with selection #3. it returns null?

after the input part it looks like this now

while (userchoice !=0){
    out.println("\nWhat would you like to do now?");
    out.println("1. Display whats on hand \n2. Edit Something\n3. Add Icing\n" +
          "4. Display Total Inventory Value\n0 to Quit ");
    userchoice = myScanner.nextInt();
  
    if (userchoice == 1){
     
        while (LoopNum>0){ // sorts the results into sequential files anf places them on different lines
       
            out.print("For the ");
            out.print(FstringArray[Num]);
            out.print(" fudge (order number ");
            out.print(FOnumArray[Num]);
            out.print("), we have ");
            out.print(FInvArray[Num] );      
            out.print(" on hand. The price for each peice is ");
            out.print(FpriceArray[Num]);
            out.println(". ");
       
   
    LoopNum--; // while there us still a array value left this counts down
    Num++; // array value
        }
        }
  
  
    if (userchoice == 2){ // edit function
      out.println("this function not yet availiable");
        }
  
  
    if (userchoice == 3){ // Method to add icing. 
        for ( int counter = 1; counter <= ALength; counter++ ){ //while loop to imput info
                    out.printf("%s.%s", num2, FstringArray[num2]);
                    num2++;
            }
        out.println("Choose Kind:");
        icingon = myScanner.nextInt();
      
        out.printf("Adding icing to %s.", FstringArray[icingon]);
      
        Wicing = FstringArray[icingon]; // gives values that can be manipulated without effecting the rest of the array
        Wicingnum = FpriceArray[icingon];// same
      
        icedfudge.addicing(Wicing,Wicingnum); // call to add icing
      
        FstringArray[icingon] = Wicing + "with icing"; // adds the "with icing" descriptor to the chosen type
        }
  
    if (userchoice == 4){
            out.print(" Total value for all fudge: "); // total value of all fudge
            out.println(TotalPrice);
         }
    if (userchoice == 0){
      out.println("Thank you for using this app!"); 
        break;
    }   
  }

the subclass has changed to

import static java.lang.System.out; // cool api I found to reduce code

class icedfudge extends fudgei
{   static double fudgeInventoryCount; // amount of peices of fudge on hand
    static double fudgePrice ; // base price of the fudge
    static double add5percent;
  

    static void addicing(String Wicing, double Wicingnum) {
        fudgePrice = fudgePrice;
        add5percent = fudgePrice*.05;
        out.println(add5percent);
    }
   
}

again any help is .. um.. helpful. i know this was shortly after the first post.

Err, which part "returns null".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.