Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:32:21+00:00 2026-06-02T08:32:21+00:00

So for my java class I have to write a program that accepts toppings

  • 0

So for my java class I have to write a program that accepts toppings and adds 75 cents to total price for every topping. I haven’t bothered for null testing yet because of this error. Essentially I will have:

list1 = Valid Toppings
list2 = User Toppings

User toppings can be entered in any order so it doesn’t make any sense to match them as a parallel array. You can see the logic I have used in the code snippet below, but it is not legal. My terminal vomits everywhere when I try to compile. How would I go about implementing the logic below, or perhaps a better way of implementing my logic completely?

  for(x = 0; toppings.length < 3; x++)
    {
      if(toppings[x].equals(for(xx = 0; validToppings[0].length < 3; xx++) {validToppings[xx]})
        {setSize(size); price += .75;}
        else
        {System.out.println("Error in Pizza class: Attempt to set invalid pizza topping" + x + "(" + toppings[x] + ")")};
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:32:23+00:00Added an answer on June 2, 2026 at 8:32 am

    I’m not sure what you’re trying to do. If you are trying to test whether one array of strings is in another array of strings, (as in, a ‘subset’ in Set Theory). Then why not use ArrayList, something like this: (sorry if my syntax is a little off it’s been a while since I did java)

    ArrayList<String> toppings = new ArrayList<>();
    toppings.add("Pepperoni");
    toppings.add("Olives");
    
    ArrayList<String> validToppings = new ArrayList<>();
    validToppings.add("Pepperoni");
    validToppings.add("Salami");
    validToppings.add("Olives");
    validToppings.add("Cheese");
    
    boolean toppingsValid = validToppings.containsAll(toppings);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assume we have a trivial Java program that consists of just one class: public
I have a Java program that loads thirdparty class files (classes I did not
I have a a Java class that gets a form definition from database then
I have a java class that applies an xslt to all xml files in
I am trying to write a java program that will automatically download and name
I'm learning java and I have made simple program that simply reads value from
I'm new to java and am trying to write a simple program that basicly
I have a simple java program that runs fine in eclipse but cannot find
I have a Java program that executes sh in interactive mode as a subprocess.
I have to write program that gets a number n from the user, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.