Question

Introduction For as long as you can remember, youve never been able to get a taco on Tuesday at your local taco dispensary.

Instructions To increase the efficiency of your code, youre going to use the Taco.java class for every taco. Youre going to

Details Input i You will be given the following parameters in this order: a boolean (shell) the shell type (hard or soft) a b

Processing Create a Taco object Assign input to Taco object Note: nextBoolean() for getting the next boolean. Print out Taco

Examples Sample input false true lettuce tomato Sample output Shell: soft Order: togo Ingredients: lettuce toma

6 import java.util.Scanner; 8 public class PoD 10 public static void main String []args ) { 11 12 13 /PLEASE START YOUR CODE

Introduction For as long as you can remember, you've never been able to get a taco on Tuesday at your local taco dispensary. The lines are always too long and the staff are very overwhelmed. You take it upon yourself to streamline the taco ordering process to decrease the mean time of getting a taco. You decide to create a process that will take customer orders and print them out in a neat and understandable format.
Instructions To increase the efficiency of your code, you're going to use the Taco.java class for every taco. You're going to write the process of creating a taco object from an order in PoD. java Once you've created a Taco object, print out the toString) method by printing out the object. Remember that you don't need to do System.out.println (taco.toString( )) Calling toString() is unnecessary.
Details Input i You will be given the following parameters in this order: a boolean (shell) the shell type (hard or soft) a boolean (togo): if the order is to eat in or out a list of ingredients ingredients): a list of Strings describing which ingredients are in the taco. The Taco.java class accepts a single String.
Processing Create a Taco object Assign input to Taco object Note: nextBoolean() for getting the next boolean. Print out Taco object Output The format of the input is given to you by the toString() method in the Taco.java object class. All you need to do is print it out.
Examples Sample input false true lettuce tomato Sample output Shell: soft Order: togo Ingredients: lettuce toma
6 import java.util.Scanner; 8 public class PoD 10 public static void main String []args ) { 11 12 13 /PLEASE START YOUR CODE HERE // 14 15 16 17 18 19 20 21 22 / *** //PLEASE END YOUR CODE HERE 23 24 25 System.out.print ("END OF OUTPUT") ; } } 26 27 28 29
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

class Taco {
private boolean shell;
private boolean togo;
String ingredients;
  
public Taco(boolean shell1, boolean togo1, String ingredients1) {
shell = shell1;
togo = togo1;
ingredients = ingredients1;
}
  
public String toString() {
String ans = "";
ans += "Shell: ";
if (shell) {
ans += "hard; ";
}
else {
ans += "soft; ";
}
ans += "Eat in or out: ";
if (togo) {
ans += "out; ";
}
else {
ans += "in; ";
}
ans += "Ingredients: ";
ans += ingredients;
ans += ".";
return ans;
}
}

public class PoD{

public static void main(String []args){
  
Scanner scanner = new Scanner(System.in);
  
Taco taco;
  
boolean shell1 = scanner.nextBoolean();
boolean togo1 = scanner.nextBoolean();
scanner.nextLine();
String ingredients1 = scanner.nextLine();
  
taco = new Taco(shell1, togo1, ingredients1);
  
System.out.println(taco.toString());
  
System.out.print("END OF OUTPUT");
}
}

false true lettuce, tomato

$javac PoD.java $java -Xmx12 8M -XM516M PoD Shell: soft; Eat in or out: out; Ingredients: lettuce, tomato END OF OUTPUT

comment down for any queries

please give a thumbs up

Add a comment
Know the answer?
Add Answer to:
Introduction For as long as you can remember, you've never been able to get a taco...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA This PoD, builds off the Book class that you created on Monday (you may copy...

    JAVA This PoD, builds off the Book class that you created on Monday (you may copy your previously used code). For today’s problem, you will add a new method to the class called lastName() that will print the last name of the author (you can assume there are only two names in the author name – first and last). You can use the String spilt (“\s”) method that will split the String by the space and will return an array...

  • Introduction In this final programming exercise, you'll get a chance to put together many of the...

    Introduction In this final programming exercise, you'll get a chance to put together many of the techniques used during this semester while incorporating OOP techniques to develop a simple song playlist class. This playlist class allows a user to add, remove and display songs in a playlist. The Base Class, Derived Class and Test Client Unlike the other PAs you completed in zyLabs, for this PA you will be creating THREE Java files in IntelliJ to submit. You will need...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • For this assignment your job is to create a two class application that examines the concept...

    For this assignment your job is to create a two class application that examines the concept of a numerical palindrome. A numerical palindrome is a non-negative whole number that is the same forwards and backwards, e.g. 2332, 12321, etc. Here's the catch: suppose you do the following. Start with any positive whole number. If it's a palindrome, you're done; if it isn't, reverse the number, add the reversal to the original value, and test this new result. It it's a...

  • You are going to write an object that takes a word (or short phrase) as an...

    You are going to write an object that takes a word (or short phrase) as an input for the Constructor and then will reverse the letters in the word. The object to implement this is referred to as **ReverseWord** and consists of **only** the following public methods: **public void setWord(String word)** - Sets the word to be processed. **public String getWord()** - Returns the word that is set with **setWord**. Note that if this is called before setWord then an...

  • Java Concurrency! You have been given a simple API to buy and print postage. Write a...

    Java Concurrency! You have been given a simple API to buy and print postage. Write a program that submits each incoming order to the API and then prints the shipping label. Unfortunately each call to the shipping label API is SLOW… To compensate for this, use concurrency so that your program can be making several calls to the API at one time. We also need to keep track of our expenses, so make sure to calculate how much money is...

  • OUTCOMES After you finish this assignment, you will be able to do the following: Define an...

    OUTCOMES After you finish this assignment, you will be able to do the following: Define an abstract class Create concrete classes from an abstract class Overload an operator Split classes into .h and .cpp files Open files for reading Write to files Use output manipulators such as setw, fixed, and setprecision DESCRIPTION A binary arithmetic operation takes two double operands (left and right) to perform addition, subtraction, multiplication, or division on. For example, 10 + 11 is an addition (+)...

  • JAVA you have been given the code for Node Class (that holds Strings) and the LinkedList...

    JAVA you have been given the code for Node Class (that holds Strings) and the LinkedList Class (some methods included). Remember, you will use the LinkedList Class that we developed in class not Java’s LinkedList Class. You will add the following method to the LinkedList Class: printEvenNodes – this is a void method that prints Nodes that have even indices (e.g., 0, 2, 4, etc). Create a LinkedListDemo class. Use a Scanner Class to read in city names and store...

  • Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...

    Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT