Parallel Arrays
Summary
In this lab, you use what you have learned about parallel arrays to complete a partially completed Java program. The program should either print the name and price for a coffee add-in from the Jumpin’ Jive coffee shop or it should print the message: "Sorry, we do not carry that.". Read the problem description carefully before you begin. The data file provided for this lab includes the necessary variable declarations and input statements. You need to write the part of the program that searches for the name of the coffee add-in(s) and either prints the name and price of the add-in or prints the error message if the add-in is not found.
Instructions
Cream Caramel Whiskey chocolate Chocolate Cinnamon Vanilla
// JumpinJive.java - This program looks up and prints the names
and prices of coffee orders.
// Input: Interactive.
// Output: Name and price of coffee orders or error message if
add-in is not found.
import java.util.Scanner;
public class JumpinJive
{
public static void main(String args[]) throws
Exception
{
// Declare variables.
String
addIn; // Add-in ordered
by customer.
final int NUM_ITEMS = 5; // Named
constant
// Initialized array of
add-ins.
String addIns[] = {"Cream",
"Cinnamon", "Chocolate", "Amaretto", "Whiskey"};
// Initialized array of add-in
prices.
double addInPrices[] = {.89, .25,
.59, 1.50, 1.75};
boolean foundIt;
int
x; //
Loop control variable.
double orderTotal = 2.00; // All
orders start with a 2.00 charge
// Get user input.
Scanner input = new
Scanner(System.in);
System.out.print("Enter coffee
add-in or XXX to quit: ");
addIn = input.nextLine();
// Write the rest of the program
here.
} // End of main() method.
} // End of JumpinJive class.
How to make this work?
import java.util.Scanner;
public class JumpinJive
{
public static void main(String args[]) throws Exception
{
// Declare variables.
String addIn; // Add-in ordered by customer.
final int NUM_ITEMS = 5; // Named constant
// Initialized array of add-ins.
String addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto",
"Whiskey"};
// Initialized array of add-in prices.
double addInPrices[] = {.89, .25, .59, 1.50, 1.75};
boolean foundIt;
int x; // Loop control variable.
double orderTotal = 2.00; // All orders start with a 2.00
charge
// Get user input.
Scanner input = new Scanner(System.in);
System.out.print("Enter coffee add-in or XXX to quit: ");
addIn = input.nextLine();
do{
// making foundIt false for every item
foundIt=false;
//iterating the items array
for(x=0;x<addIns.length;x++){
//checking if item found in
list
if(addIns[x].equals(addIn)){
//if found
getting the price from the prices array
orderTotal+=addInPrices[x];
//adding to the
total
foundIt=true;
//breaking the
loop
break;
}
}
//checking if the item found in the array
if(!foundIt){
System.out.println("Sorry, we do
not carry that");
}
System.out.print("Enter coffee add-in or XXX to quit:
");
addIn = input.nextLine();
}while(!addIn.equalsIgnoreCase("XXX"));
System.out.println("Order total: "+orderTotal);
// Write the rest of the program here.
} // End of main() method.
} // End of JumpinJive class.

Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to...
5 5 - Parallel Arrays in Python Mind Tap - Cengage Lea x + V A https//ng.cengage.com/static/nb/ui/evo/index.html?deploymentid=5745322406056533358933471518eISBN=9781337274509&id=586434 145&snapshotld: L x ... € → O 1 » CENGAGE MINDTAP Q Search this course x Parallel Arrays in Python D Parallel Lists Jumpinjive.py + > Terminal + 1 # Jumpin Java.py - This program looks up and prints the names and prices of coffee orders. 2 # Input: Interactive 3 # Output: Name and price of coffee orders or error message if...
Design a program that has two parallel arrays: a String array named people that is initialized with the names of seven of your friends, and a String array named phoneNumbers that is initialized with your friends’ phone numbers. The program should allow the user to enter a person’s name (or part of a person’s name). It should then search for that person in the people array. If the person is found, it should get that person’s phone number from the...
This program will simulate buying a cup of coffee. The initial cost of a cup of coffee will be $2.00 (without adding items). This program will demonstrate a concept called parallel arrays. Parallel arrays are arrays that have the same number of items. For Python we will use lists. You will have a list that holds addingitems which will consist of a list equal to Cream, Caramel, Whiskey, Chocolate, Cinnamon and Vanilla. You will then have a parallel list of...
In Java.
Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
In this module, you learned about Arrays in C++ and how to implement arrays within your C++ programs. For this assignment, you will implement your knowledge of arrays for Michigan Popcorn Company’s sales management system. Write a program that lets the Michigan Popcorn Company keep track of their sales for seven different types of popcorn they produce: plain, butter, caramel, cheese, chocolate, turtle and zebra. It should use two parallel seven-element arrays: an array of strings that holds the seven...
The Jumpin Jive coffee shop charges $2 for a cup of coffee and offers add ins shown in the pseudocode. Using the following Pseudocode, Design the logic for an application that allows a user to enter ordered add ins continuously until a sentinel value is entered. After each item, display its price or the message "Sorry, we do not carry that" as an output. After all items have been entered, display the total price for the order. Please write it...
I need to write a loop that examines the names of the cities stored in the array. Write code that tests for a match Write code that, when appropriate, prints the message: Not a city in Illinois _______________________________________________________________ ' IllinoisCities.vb - This program prints a message for invalid cities in Illinois. ' Input: Interactive ' Output: Error message or nothing Option Explicit On Option Strict On Module IllinoisCities Sub Main() ' Declare variables. Dim city As String ...
Java programming question: Here is the feedback I received "sort fails. Use Arrays class method to sort." The actual question: Write a program as follows: Declare a five element array of Strings. Use a for loop and keyboard input to populate the array with the names of five friends. Sort the array in alphabetical order. Use a foreach loop to print the sorted array of friends, all on one line. Sample Output (inputs in italics) Enter the names of five...
Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in one of two ways. In one method, the array elements are placed in a list enclosed in curly braces after the array name definition. For example, the code below creates an array of ints with 3 elements: 1, 2 and 3. int[] a = {1, 2, 3, 4}; We can also initialize an array with a new construct, indicating how many elements we want...
This lab is to give you more experience with C++ Searching and Sorting Arrays Given a file with data for names and marks you will read them into two arrays You will then display the data, do a linear search and report if found, sort the data, do a binary search. Be sure to test for found and not found in your main program. Read Data Write a function that reads in data from a file using the prototype below....