Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a program that will use a loop to accept the names of one thousand items

ID: 3544401 • Letter: D

Question


Design a program that will use a loop to accept the names of one thousand items and the cost of each item. The names and the item costs will be stored in two parallel arrays.  The program will then output the names, item costs and item prices (calculated using: itemCost(x) * 1.3) in table form with the text "Item Name" on top of the names and "Item Cost" on top of the costs and "Item Price" on top of the prices.  Here are some hints:
  • You will require two parallel arrays for the input and an additional parallel array for the output.
  • Do not attempt to format the output (except as directed below).
  • Make sure you include at least five spaces between the item names, the item costs and the item prices.

Explanation / Answer

public class parallelArray {

public static void main(String[] args){


String A[] = {Apple, shirt, shoes, headphones}; // enter 1000 items here using comma...

double B[] = {2, 3, 4.5, 8.9 }; // enter 1000 values here...

double C[] = new double[4]; // change 4 to 1000 when u submit


System.out.println("ItemName ItemCost ItemPrice");

for(int i=0;i<4;i++){ //Change 4 to 1000 when u add all the values above... if u don't it goes for exeception

C[i] = B[i]*1.3;

System.out.println(A[i]+" $"+ (B[i])+" $"+(C[i]));

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote