I'm writing this code for one of my projects. can you please help me with line #6,#7 and #10? I'm not sure if I am writing the code for those correctly.

package waffles; 
import java.util.Scanner; 
import java.util.Stack; 

/** 
* 
*/ 
public class Waffles { 

/** 
* @param args the command line arguments 
*/ 
public static void main(String[] args) { 
#2&3 Stack<String> waffleStack= new Stack<String>(); 
Scanner keyboard = new Scanner(System.in); 
//Bonus waffles are either millk or berry. 
String buckwheat = "Buckwheat waffle"; // Standard waffles 
String blueberry = "milk waffle"; // Bonus waffles 
String strawberry = "berry waffle"; // Bonus waffles 
//Use a for loop to help the cook assemble a Stack of eight buckwheat waffles. Complete the for loop and add the missing statement so the eight waffles are placed on the stack. 
#4&5. for(int k = 1; k<=8; k++){ 
#6//Now choose some additional Special-Challenge waffles for a friend to eat. 
// Add as many as you want. Special Vs must be milk or berry. 
wafflesStack.push("milk waffles") ; 
wafflesStack.add("berry waffles"); 
} 
#7 // Use the customized static print method below to display the Stack of waffless your sponsoree must eat. 
System.out.println("\n sponsoree must eat: "+waffleStack.size()); 

// Let the contest begin! Start eating waffless using a while loop! 
// Earn $2 for each buckwheat waffles you eat, and earn $5 for each bonus waffles 
int numberEaten = 0; int moneyEarned = 0; String nextWaffle; 
boolean done = false; 
while(!done) { 
// 8. Check if the waffles stack is empty! Don't try to eat the plate!! 
if( WaffleStack.isEmpty()){ 
System.out.println("\n\nAll the waffles have been eaten! Good job!\n" );break;} 
nextWaffle = waffleStack.peek(); // Peek at, but to not remove the next waffle. 
System.out.println("\nThe next waffle is a : " + nextWaffle ); System.out.println("\nType any key to make your sponsoree eat the waffle, or type Q when done."); 
String newName = keyboard.next(); 
if(newName.equalsIgnoreCase("Q")) done = true; 
#9. else{waffleStack.remove(newName);//#9Eat the waffle by removing it from the stack. 
numberEaten++;// Great! Your sponsoree has eaten one more! What a champ! 
// 10. If the nextwaffles is not buckwheat, your sponsoree earns $5 else they earn $2. You must use the ! operator 
if(!nextWaffles.contains("Buckwheat waffle")) 
moneyEarned+=5; else moneyEarned +=2; 
} //end of else block   
System.out.printf("\nWow, your sponsoree has eaten %d waffles and earned %d dollars.\n", numberEaten, moneyEarned); 
} // end of while loop System.out.printf("\nWow, your total is %d waffless and %d dollars.\n", numberEaten, moneyEarned); 
} // end of main method 

// Custom method to print a Stack. 
public static void print(Stack<String> myStack ) { 
int count = 1, sizeOfStack = myStack.size(); 
System.out.println("\nYour stack has size: " + myStack.size()); 
for (String myString : myStack) 
{System.out.print(count + ". " + myString); 
if(count!=sizeOfStack) System.out.print( " -> "); 
else System.out.print( " :Last"); 
count++;

Please make sure your code is properly indented before pasting it into the postings. If it was indented before, then you may be having problems pasting it. For the meanwhile, I'll run the code through AStyle to get it formetted usefully:

package waffles;
import java.util.Scanner;
import java.util.Stack;

/**
*
*/
public class Waffles {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
        Stack<String> waffleStack= new Stack<String>();
        Scanner keyboard = new Scanner(System.in);
//Bonus waffles are either millk or berry.
        String buckwheat = "Buckwheat waffle"; // Standard waffles
        String blueberry = "milk waffle"; // Bonus waffles
        String strawberry = "berry waffle"; // Bonus waffles
//Use a for loop to help the cook assemble a Stack of eight buckwheat waffles. Complete the for loop and add the missing statement so the eight waffles are placed on the stack.
        for(int k = 1; k<=8; k++) {
//Now choose some additional Special-Challenge waffles for a friend to eat.
// Add as many as you want. Special Vs must be milk or berry.
            wafflesStack.push("milk waffles") ;
            wafflesStack.add("berry waffles");
        }
// Use the customized static print method below to display the Stack of waffless your sponsoree must eat.
        System.out.println("\n sponsoree must eat: "+waffleStack.size());

// Let the contest begin! Start eating waffless using a while loop!
// Earn $2 for each buckwheat waffles you eat, and earn $5 for each bonus waffles
        int numberEaten = 0;
        int moneyEarned = 0;
        String nextWaffle;
        boolean done = false;
        while(!done) {
// 8. Check if the waffles stack is empty! Don't try to eat the plate!!
            if( WaffleStack.isEmpty()) {
                System.out.println("\n\nAll the waffles have been eaten! Good job!\n" );
                break;
            }
            nextWaffle = waffleStack.peek(); // Peek at, but to not remove the next waffle.
            System.out.println("\nThe next waffle is a : " + nextWaffle );
            System.out.println("\nType any key to make your sponsoree eat the waffle, or type Q when done.");
            String newName = keyboard.next();
            if(newName.equalsIgnoreCase("Q")) done = true;
            else {
                waffleStack.remove(newName);//#9Eat the waffle by removing it from the stack.
                numberEaten++;// Great! Your sponsoree has eaten one more! What a champ!
// 10. If the nextwaffles is not buckwheat, your sponsoree earns $5 else they earn $2. You must use the ! operator
                if(!nextWaffles.contains("Buckwheat waffle"))
                    moneyEarned+=5;
                else moneyEarned +=2;
            } //end of else block
            System.out.printf("\nWow, your sponsoree has eaten %d waffles and earned %d dollars.\n", numberEaten, moneyEarned);
        } // end of while loop System.out.printf("\nWow, your total is %d waffless and %d dollars.\n", numberEaten, moneyEarned);
    } // end of main method

// Custom method to print a Stack.
    public static void print(Stack<String> myStack ) {
        int count = 1, sizeOfStack = myStack.size();
        System.out.println("\nYour stack has size: " + myStack.size());
        for (String myString : myStack)
        {   System.out.print(count + ". " + myString);
            if(count!=sizeOfStack) System.out.print( " -> ");
            else System.out.print( " :Last");
            count++;

As you cane see, proper styling highlights exactly where at least some of the problems lie.

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.