Ask Computer Engineering Expert

Problem 1 - no methods required

When the user runs this block of code, the values in the array will be displayed, along with a sum value, the lowest value, and the number of occurrences of the lowest value. Appropriate data types are required, and use the Length property of the array to control all looping
constructs except the ‘foreach'. Here are the steps to follow:

a. Declare an integer constant for the SIZE of the array, the size will be 25.

b. Declare and instantiate an integer array with the name testScores using the constant SIZE. Make sure to use the "new" operator.

c. Use a ‘for' loop to populate the array with random numbers from 10 to 100 inclusive. Use constants.

d. Use a ‘while' loop structure to accumulate the values that are in the array. Store that value in a variable named sum.

e. Do not sort the array, and use a ‘do' loop to determine the lowest value in the array. Keep it simple, you do not have to create a sorting routine. (Hint: store the first value in the array into a variable called low. Inside the loop compare low to the next element in the array. If it is less, then store the array value into low. Repeat until you reach the end of the loop.)

f. Use a foreach loop to display the values in the array on one line with spaces between each number. (See below) Within this loop, count the number of times the highest value occurs in the array.

g. Using one CW, display the sum (including comma), the lowest value and the number of occurrences of the lowest value. (See below)
Required output [values listed will vary]:

Problem 1

82  87  90  91  87  88  96  92  97  100  92  92  86  94  81  88  82  92  98  92  99  85  86  81  86

Sum of values: 2,244

Lowest value: 81 occurs 2 time(s).

Problem 2

Description: Use two single dimension arrays, where one will be a Lookup Table to determine the cost of an individual item in an outlet retail store. The user will input the item (string) and the quantity (integer) purchased; then the program will determine the price (fractional number) for the item and display the total cost (fractional number) for that purchase. This will use methods, and you do not need to validate the data. Define the methods for this question directly under Main; there are comments to guide you, and above the Pause() method, and in the same Class. Reminder to not use class level variables, and accept user mixed case input for the item purchased. A fractional number is data that allows decimal points. Use the following pseudocode to guide you.

a. Declare and initialize two arrays, arrItem (Item) and arrPrice (Price) and use the “new” operator when declaring the arrays. Use the following data to initialize the arrays and do not change the order as shown.

Item           Price
laptop        925.25
keyboard    52.00
mouse        15.75
monitor       95.50

Use 1 C# statement for each array to declare and initialize the values in them. Declare the arrays within Main()

b. In Main, call the methods to get the item and the quantity. (see steps f and g)

c. In Main(), use the item array to determine the subscript/index value to use for the price.

Use a ‘for’ repetition structure and not the binary search to determine the index value to use as a Lookup in the price array.
d. If the user inputs an invalid item, display an error message that repeats the value the user entered. See example after this question. Do not add a loop to ensure valid data.

e. If the data is valid, call the CalcItemCost method (see step h) and display the total cost formatted with a dollar sign and two decimal places.

f. Method GetItem – Parameters: none; return: item Prompt for the item, and convert the input value all to lower case.

g. Method GetQuantity – Parameters: none; return: quantity of items purchased as a whole number.
Prompt for the quantity of items purchased.

h. Method CalcItemCost – Parameters: the number of items, the cost for the item; returns: the calculated total cost. A tax of 9.5% is included in the total cost, and this method will not get nor display any data to the console. Create and use a constant for the tax rate.

See examples of the prompts, and text below. Use Write instead of WriteLine for the prompts.

Required display :

Problem 2

Enter the item to purchase: Keyboard

Enter the number of items purchased: 10

Total cost for the purchase is: $569.40

Required display [Error]:

Problem 2

Enter the item to purchase: diskette

Enter the number of items purchased: 20

Invalid entry, diskette does not exist.

Problem 3

Description: Within Main(), Problem 3 curly braces, this section will call 3 methods which will be created directly below CalcTicketCost() method and right above the Pause() method. Do not declare any class level variables; use only local variables in each code block and method. Data types must match as arguments and parameters, an implicit conversion will be marked as incorrect.

a. In this code block, prompt the user for three integer values and store into appropriate data type variables. You do not need to validate the data, but you must use TryParse, and numbers can be positive or negative. Use Write instead of WriteLine for the prompts.

Within the class, create the 3 methods as describe: Product(), Division(), Average()

b. Product() with three parameters. The parameter names must be different than the variables stored in the Problem 3 code block.
Calculate the product and return the value

c. Division() with two parameters – the first parameter is the dividend, the second parameter is the divisor. The parameter names must be different than the variables stored in the Problem 3 code block.

In this example (571/13), 571 is the dividend, and 13 is the divisor

Calculate the result (no truncated values) and return the value.

Check for zero division. To keep this simple, if this error occurs, return a negative 999.99.

d. Average() with three parameters. The parameter names must be different than the variables stored in the Problem 3 code block.

e. In this Problem 3 code block, call each of the methods, with the following arguments:

a. Product: use all three input numbers as arguments

b. Division: use the “first two” input numbers as arguments

c. Average: use all three input numbers as arguments

f. Use one WriteLine to display the resulting values with appropriate labels. Show the product with commas, and no decimal places, except show the division and average results with 2 decimal places.

Required display [example1]:

Problem 3

Enter number 1: 543

Enter number 2: 000

Enter number 3: 21

The results of the three method calls are:

Product: 0

Division: -999.99

Average: 144.00

Required display [example2]:

Problem 3

Enter number 1: 25

Enter number 2: 52

Enter number 3: 33

The results of the three method calls are:

Product: 42,900

Division: 0.48

Average: 36.67

Challenge

Write a program that allows the user to enter any amount of numbers (double data type) continuously until the user enters 999; use a ‘do’ construct. Display the number of values entered and the sum of the values entered, not including 999, with commas and 2 decimal places. Use a constant for the value that ends the repetition.

Required display:

Enter a number: 1010

Enter a number: 100.10

Enter a number: 10.01

Enter a number: 999

You entered 3 numbers and the sum is 1,120.11

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91327838
  • Price:- $40

Guranteed 36 Hours Delivery, In Price:- $40

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As