1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kaylis [27]
3 years ago
11

Write a program for a grocery store to calculate the total charge for customers. In the main: Your program should ask customer t

he number of items that he/she is purchasing and it should check to see it is less than or equal to 20 items , then your program should pass than number to FillPriceArray subroutine and call FillPriceArray subroutine.
Computers and Technology
1 answer:
gavmur [86]3 years ago
8 0

Answer:

Hello Joelwestwood! This is a good question to check your knowledge of subrountines and Arrays. Please find the implementation with the explanation below.

Explanation:

The solution can be implemented in a number of languages including C++, Java and Python to name a few. Though the implementation language is not specified in the question, i'll provide you the implementation code in Python and also in Java. Java implementation is a little complex because we need to define an array size to be able to add items to it, whereas Python allows us more flexibility by allowing dynamic size of Array.

JAVA IMPLEMENTATION

import java.util.Scanner;

import java.util.Arrays;

class TotalCharge {

 private static int[] price_array = new int[1];

 public void FillPriceArray(int price) {

   if (price_array.length == 1) {

     price_array[0] = price;

   } else {

     price_array = new int[price_array.length + 1];

     price_array[price_array.length + 1] = price;

   }

 }

 public int[] get_price_array() {

   return price_array;

 }

 public static void main(String args[]) {

   System.out.println("Please enter the total number of items to purchase: ");

   Scanner scan = new Scanner(System.in);

   int price = scan.nextInt();

   if (price <= 20) {

     System.out.println("Items being purchased are less than 20");

   } else {

     System.out.println("Items being purchased are more than 20");

   }

   TotalCharge itemsTotal = new TotalCharge();

   itemsTotal.FillPriceArray(price);

   System.out.println(Arrays.toString(itemsTotal.get_price_array()));

 }

}

PYTHON IMPLEMENTATION

calculate_total_charge.py

def FillPriceArray(price):

 price_array.append(price)

price_array = []

price = raw_input("Please enter the total number of items to purchase: ")

try:

 price = int(price)

 if price <= 20:

   print("Items being purchased are less than 20")

 else:

   print("Items being purchased are more than 20")

 FillPriceArray(price)

 print(price_array)

except ValueError:

 print("Invalid input! Exiting..")

You might be interested in
Chapter 20 reading and vocab review
aev [14]

Answer:

Essentially additive editing and stringing “the good stuff” together, whereas subtractive is more about stringing all your raw footage together and “removing the bad stuff”

Additive editing feels confident and concerned with the pursuit of a specific, existing vision. And it’s faster. Subtractive editing feels like a deeper listening to what the footage is saying, and holding on to many potential permutations.

Explanation:

Addictive editing -  creating a program from raw footage by starting by starting with nothing and adding selected components

Subtraction editing  - creating a program by removing redundant or poor quality material from the original footage

7 0
2 years ago
Which of the following best describes a proxy firewall? A. It sends traffic through another host. B. It acts as a gateway for re
12345 [234]
The answer would be B, for your computer is considered a client instead of server.
6 0
3 years ago
What happens when variables in programming are not properly initialized? answers?
Romashka-Z-Leto [24]
Errors in compilation happen, or it runs but then doesn't recognize the input. Also you can't transform into other types of variables.
6 0
3 years ago
Process redesign and reengineering in 1500 words
timama [110]

Answer:

Process re-design is the process in which re-work is done to achieve the improvement in the output. The major aim is to set the goals for achieving the main objective.

The various essential steps in the process of re-design are:

  • Data capturing process are used to identify the process and making the necessary changes.
  • Identify every step of the process to ensure that process is in organized way along with the workflow.

Re-engineering is the process of re-design the system with focuses to improve the efficiency and quality. It basically analysis the whole business re-engineering process. The main step is to identify the need for the changes.

 

7 0
3 years ago
Please help me idk I suck at this stuff ​
kap26 [50]
I would say the best clear answer is D, because A is a little bit unclear but I would say the best answer is D.

Why?

Mesh Topology is expensive considering more links as compared to Ring topology.


4 0
3 years ago
Other questions:
  • What would I need to make the perfect music video
    10·1 answer
  • Which of the following are incorrect safety precautions for equipment operators? A. Drive equipment or vehicles on grades or roa
    7·2 answers
  • How to send an email
    7·2 answers
  • The security manager assigned a new security administrator the task of implementing secure protocols on all wireless access poin
    9·1 answer
  • Which two encryption protocols might be used to provide secure transmissions for browser and web server communications?
    14·1 answer
  • Should organizations fear websites where consumers post negative messages about products or services? What actions can companies
    12·1 answer
  • The function of anOR gate can best be described as a gate which provides an output of 1 only when
    10·1 answer
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • We begin with a computer implemented in a single-cycle implementation. When the stages are split by functionality, the stages do
    13·1 answer
  • Using a wireless technology known as ___, many smartphones can now be tapped on special payment devices to complete your purchas
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!