logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

how to create, populate, and access arrays using value-receiving and value-returning methods.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Purpose: To learn how to create, populate, and access arrays using value-receiving and value-returning methods.

Prep Work: Chapter 6 on arrays and Shepherd's chapter 6 PowerPoint slides.

Lab Exercise 6.2 Instructions: Code a program listing the restaurants owned and each restaurants average number of daily customers, average bill per customer, and average daily revenue.

 

  1. Prompt the user for the number of restaurants which is the size of the

  2. Using the size, the program creates several arrays that will store information about the restaurants

  1. There will be one array for the
  2. Another for the average number of daily customers,
  3. And the last one for the average bill per customer.
  4. These are 3 separate arrays that are processed together, hence known as parallel array processing

3.The values in each array at the same location are for a given restaurant. Once the arrays are populated, print the information from each

4.The size and input will be the only

5.Use printf().

6 Use the looping structure generally associated with array processing.

7.Name the program java.

 8.The methods will be called from the main().

9.Code your program according to the specifications

 

1st Input Prompt: Code this in a method named arraySize().

How many restaurants do you own?

 2nd Input Prompt: In a method named setRestaurants declare the restaurants array and populate it. This method will return the restaurants array to the calling

statement.   The 9 in the prompt below will print 1 for the first restaurant, then 2 for the 2nd one and so forth. Use the loop-control variable as the value for 9.

Enter restaurant 9:

3rd Input Prompt: In a method named setCustomers declare the noCustomers array and populate it. The Xs in the prompt is the restaurant. The setCustomers method will return the noCustomers array to the calling statement as well as receive the restaurants array from the calling statement. This method will be called as an argument in the call to printRestaurants().

Enter the average number of daily customers for Xxxxxxxxxx:

 4th Input Prompt: In a method named calcAvgDailyRev declare the avgBill array and populate it. The Xs in the prompt is the restaurant. The calcAvgDailyRev method will return the avgBill array to the calling statement as well as receive the restaurants array from the calling statement. calcAvgDailyRev() will be called as an argument in the call to printRestaurants().

Enter the average bill per customer for Xxxxxxxxxx:

Output Specifications: Where the Xs represent the restaurant and the Zs the average number of daily customers, the average bill and the average daily revenue. Code the output print statement in a method named printRestaurants() that accepts the restaurants, noCustomer, and avgBill arrays. The average daily revenue for each restaurant is to be calculated. In the printRestaurants method use a for-loop to print the information for each restaurant from each array. The print for the header has to be outside of the for-loop because it's printed only once.

 

MY RESTAURANTS

Restaurant:   Xxxxxxxxxxxxxxx Average No of Daily Customers:

Z,ZZ9 Average Bill Per Customer:     $ZZ,ZZ9.99

Average Daily Revenue:   $ZZZ,ZZZ,ZZ9.99

Restaurant: Xxxxxxxxxxxxxxx

Average No of Daily Customers:    

 Z,ZZ9 Average Bill Per Customer:

 $ZZ,ZZ9.99 Average Daily Revenue:

 $ZZZ,ZZZ,ZZ9.99

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

964 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

957 Answers

Hire Me
expert
Husnain SaeedComputer science

887 Answers

Hire Me
expert
Atharva PatilComputer science

686 Answers

Hire Me