Enhance the pseudocode using arrays and loops

Assignment Help Data Structure & Algorithms
Reference no: EM13945620

Enhance the pseudocode in the attachment by using arrays and loops. Also, instead of hardcoding the product names within the program, ask the user to enter the product names in addition to the prices.

You can use char array products[5][40] and float array prices[5] to store the names and prices respectively (use "char products[6][40]" and "float prices[6]" if you want to simplify the code at the expense of a few more bytes of memory). Feel free to define additional arrays if needed.

main():

prompt the user to enter the price for apple
read apple_price

prompt the user to enter the price for banana
read banana_price

prompt the user to enter the price for grapes
read grapes_price

prompt the user to enter the price for pears
read pears_price

prompt the user to enter the price for tomato
read tomato_price

do
prompt whether the user wants to do checkout
read response
if response is yes then
invoke checkout()
endif
while response is yes;

print "Thanks for using checkout program".

checkout():

initialize total to 0

do

list the products
print 1. apples
print 2. banana
print 3. grapes
print 4. pears
print 5. tomatos

prompt the user to select a product or enter 0 for complete checkout
read selection

if selection > 0 then
prompt the user to enter weight
read weight

// you can alternatively use select ... case ... end structure when coding.

if selection is 1 then
add (weight * apple_price) to total
endif

if selection is 2 then
add (weight * banana_price) to total
endif

if selection is 3 then
add (weight * grapes_price) to total
endif

if selection is 4 then
add (weight * pears_price) to total
endif

if selection is 5 then
add (weight * tomato_price) to total
endif
endif
while selection is not 0;

if total > 50
apply 5% discount
output the discount and the new total
else
output total
endif

Reference no: EM13945620

Questions Cloud

Find the maximum height and range : Problem 1: ForΔdy = 0 and for any given vo find θ so that the range (Δdx) is maximum. Problem 2: Find the maximum height (h) and range for vo = 10 m/s, θ = 30°, and Δdy = -10 m. What is the flight time? Problem 3: Find the maximum height and range fo..
Understanding of the unit materials : Assignments are designed for you to show your understanding of the unit materials. Make references to lesson materials, researched material, and Seminars as needed, using APA format.
What is the probability that the customer can drive : A particular customer lives 25 minutes from Collina's Italian Caf. If the customer places a telephone order at 6:00 P.M., what is the probability that the customer can drive to the caf, pick up the order, and return home by 7:00 P.M.?
The impact of migration on rates of tb infection : Significance The purpose of this research study is to investigate the correlation between the high incidence and prevalence trends in tuberculosis TB infections in Monrovia and rural-urban migration drift in Liberia.
Enhance the pseudocode using arrays and loops : Enhance the pseudocode in the attachment by using arrays and loops. Also, instead of hardcoding the product names within the program, ask the user to enter the product names in addition to the prices
Correlation between the high incidence and prevalence : Significance The purpose of this research study is to investigate the correlation between the high incidence and prevalence trends in tuberculosis TB infections in Monrovia and rural-urban migration drift in Liberia. Although a many studies lot of..
Define evacuation control techniques in volcanic disasters : Describe evacuation and crowd control techniques in volcanic disasters. Describe how you would have applied these techniques to the eruption of the Mount Pinatubo.
Briefly introduce your organization in terms of name : Briefly introduce your organization in terms of name, the industry it operates within, products and services, clients, suppliers, major competitors and competing products
Proposed design suitable for the duty : Ammonia vapor, 4500kg/h at 6.7 bara pressure, is to be cooled from 120oC to 40oC, using cooling water. The maximum supply temperature of the cooling water available is 30oC, and the outlet temperate is to be restricted to 40oC. The pressure drops ove..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd