CSCI 1500 Array and Matrix Problems

Verified

Added on  2019/09/16

|2
|890
|424
Homework Assignment
AI Summary
This assignment focuses on solving four programming problems using arrays and matrices in C++. The problems include generating the Fibonacci sequence, finding the lowest price among computer stores, calculating salesperson commissions and salary ranges, and summing columns in a 2D array. Students are required to write pseudocode for each problem, convert it into C++ code, and submit both. The assignment emphasizes proper coding guidelines, data types, and program output formatting. The solutions provided include detailed pseudocode and C++ code for each problem, along with sample outputs.
tabler-icon-diamond-filled.svg

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Write a detailed pseudocode solution for each of the following problems. Then, using your
pseudocode, convert your pseudocode into C++ programs. Here are the things you need to do for
each problem:
Design your solutions to produce the program output like that given for each of the
problems. Note: Your program should work correctly for any valid user input, not just for
the example user input values given.
Convert your pseudocode into C++ code. Follow the coding guidelines specified in the
Coding Guidelines posted on D2L. Remember to use appropriate data types for all variables.
Remember to include each name of your group in a comment at the top of the program.
Compile and run the program and verify that it works properly for a variety of input values.
What you need to turn in: A printed copy of your pseudocode and your C++ code for each of
the problems, arranged in order, and stapled together. Include each name of your group on the
front page of what you turn in. Clearly identify which pseudocode and C++ code solves which
problem. Use a word processor to write and print your pseudocode. Email all source code (.cpp
files) as individual attachments. On the subject line, put CSCI 1500 & the assignment number.
1. Arrays The Fibonacci sequence is a list of numbers in which the first two numbers in the list
are both one and each successive number is the sum of the previous two numbers. This means
that the first eight Fibonacci numbers are 1, 1, 2, 3, 5, 8, 13, 21. Write a program that will
calculate and store the first 20 Fibonacci numbers in an array. Then print a table consisting of
each of the first 20 Fibonacci numbers greater than one along with the ratio of that Fibonacci
number to its predecessor, shown to 8 digits of accuracy. Here is what the first few lines of
output should look like from running your program:
FIB# RATIO
2 2.00000000
3 1.50000000
5 1.66666667
8 1.60000000
13 1.62500000
21 1.61538462
2. Arrays Write a program that will prompt for and read in a list of up to ten computer store
names and the corresponding price that each store charges for a particular model of PC, and will
then determine the lowest price charged for that PC among the stores input. Then, the program
should print two lists:
List 1 – The names of all stores charging the lowest price.
List 2 – The names and prices for all stores whose price does not exceed the lowest price
by more than 10%.
Hint: Use two arrays - one to store the names and the other to store the prices.
3.Arrays of Counting Variables. A company pays its salespeople on a commission basis. The
salespeople receive a weekly take-home salary of $200 per week plus 9% of their gross sales for
that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus
9% of $5000, or a total of $650. Write a program that will repeatedly prompt for and read in a
weekly gross sales amount for each individual salesperson and then calculate and display her
take-home salary. In addition, the program should calculate and display the combined total
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
weekly sales for all of the salespeople, the combined total take-home salary for all of the
salespeople, the total number of salespeople, and a summary of how many of the salespeople
earned salaries in each of the following ranges (assume that each salesperson’s weekly salary is
truncated to an integer amount):
$200-$299 $300-$399 $400-$499
$500-$599 $600-$699 $700-$799
$800-$899 $900-$999 $1000 and over
Use an array of counters to count these totals. Note: Assume that the user of the program
does not know how many salespeople there are in advance. To see a sample output from the
program, run the program Assign6_3.exe which can be obtained from the Share file server:
S:\Coursework\Liu\CSCI1500 on campus.
4.Matrix/2-d Array. Write a program that reads in the values of a table consisting of three rows
and three columns of integers, one row at a time into a 3 x 3 array or matrix and then displays
the table followed by the column totals (i.e., the sums of the numbers in each of the three table
columns). Here is an example of what output should look like from running your program (user
input shown in bold):
Enter row 1: 1 2 3
Enter row 2: 4 5 6
Enter row 3: 3 2 1
Table:
1 2 3
4 5 6
3 2 1
------
8 9 10
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]