Menu

[Solved] Parallel Arrays Summary Lab Use Learned Parallel Arrays Complete Partially Completed Java Q37172880

Parallel Arrays

Summary

In this lab, you use what you have learned about parallel arraysto complete a partially completed Java program. The program shouldeither print the name and price for a coffee add-in from theJumpin’ Jive coffee shop or it should print the message:“Sorry, we do not carry that.”. Read the problemdescription carefully before you begin. The data file provided forthis lab includes the necessary variable declarations and inputstatements. You need to write the part of the program that searchesfor the name of the coffee add-in(s) and either prints the name andprice of the add-in or prints the error message if the add-in isnot found.

Instructions

  1. Study the prewritten code to make sure you understand it.
  2. Write the code that searches the array for the name of theadd-in ordered by the customer.
  3. Write the code that prints the name and price of the add-in orthe error message, and also write the code that prints the totalorder cost.
  4. Execute the program using the following data:

CreamCaramelWhiskeychocolateChocolateCinnamonVanilla

// JumpinJive.java – This program looks up and prints the namesand prices of coffee orders.
// Input: Interactive.
// Output: Name and price of coffee orders or error message ifadd-in is not found.

import java.util.Scanner;

public class JumpinJive
{
   public static void main(String args[]) throwsException
   {
      // Declare variables.
      StringaddIn;        // Add-in orderedby customer.
      final int NUM_ITEMS = 5; // Namedconstant
      // Initialized array ofadd-ins.
      String addIns[] = {“Cream”,”Cinnamon”, “Chocolate”, “Amaretto”, “Whiskey”};
      // Initialized array of add-inprices.
      double addInPrices[] = {.89, .25,.59, 1.50, 1.75};
      boolean foundIt;
      intx;           //Loop control variable.
      double orderTotal = 2.00; // Allorders start with a 2.00 charge

      // Get user input.
      Scanner input = newScanner(System.in);
      System.out.print(“Enter coffeeadd-in or XXX to quit: “);
      addIn = input.nextLine();
      // Write the rest of the programhere.
    
   } // End of main() method.
} // End of JumpinJive class.

How to make this work?

Expert Answer


Answer to Parallel Arrays Summary In this lab, you use what you have learned about parallel arrays to complete a partially complet… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *