Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Question 4

A. Consider a problem to find the student who had the highest GPA for the 2020/2021 academic year.

i. Explain your choice of either a search or a sorting algorithm to solve this problem. [7.5 marks]

ii. Write the algorithm for your implementation. [7.5 marks]

B. Consider the analogy of a pile of books on a table. Using a diagram, explain the basic operations involved in adding a book to the pile and removing a book from the pile. [5 marks]

C. Use the code below to answer the questions that follow: [5 marks] public class CS204 { public static int linearSearch(int[] data, int target) { for (int i = 0; i < data; i++) { if (target == data[i]){ return i;

5

} } return -1; } public void main(String[] args) { int[] data = {3, 14, 7, 22, 45, 12, 19, 42, 6}; System.out.println("Search for 7: " + linearSearch(7)); } }

i. Why is method linearSearch declared static?

ii. Identify and resolve the errors in the code.


Question 2

A. A module is required to enable lecturers to easily identify the highest and lowest performing students in their courses. As the lead programmer, write a java program to achieve this. Your program should have the following features:


i. The program should make use of a sentinel to control the number of grades entered.

ii. Total Number of grades entered

iii. The average of the grades

iv. Number of students that achieved a grade of 80 and above

v. Number of students that achieved a grade of 50 and below

[15 marks]

B. An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. Write an algorithm for the implementation of the sentinel control in Question A Sub Question I above. [5 marks]

C. For larger datasets, a linear search may be inadequate or perhaps inefficient. What other search method can be employed to return the maximum number from a set of elements in an array. Explain your answer.

Question 1

A. Write a java program that reads three (3) int variables and performs the below operations:

i. Prints out their product

ii. Prints out the maximum of the numbers

Do not use any inbuilt Java Methods to return the maximum.

Extra marks will be awarded for clarity of code and comments.

[8 marks]

B. Algorithms perform differently on different data sets and as such we may be interested in either their Best-case, Worst-case or Average-case scenarios. Explain why the Worst-case for an insertion sort is with reverse-sorted data. [6 marks]

C. Identify and correct the errors in each of the following sets of code: [6 marks]

i.

while ( c <= 5 )

{

product *= c;

++c;

ii.

if ( gender == 1 )

System.out.println( "Woman" );

else;

System.out.println( "Man" );

iii. What is wrong with the following while statement?

while ( z >= 0 )

sum += z;

D. Explain two (2) programming situations that will require the use of overloaded


Write a C++ program that will input an employee's monthly sales and calculate the gross pay, deductions, and net pay. Each employee will receive a base pay of $1000 plus a sales commission. The amount of sales commission will depend on the monthly sales of the employee as given in Table 1 below:

Table 1 Commission Rates Monthly Sales Commission Greater than or equal to $50,000 16% of sales Less than $50,000 but greater than or equal to $40,000 12% of sales Less than $40,000 but greater than or equal to $30,000 10% of sales Less than $30,000 but greater than or equal to $10,000 6% of sales Less than $10,000 3% of sales Table 2 below gives a short description of all the elements important to the calculation of the pay of the employee. Table 2 Base pay $1000; use a named constant Commission Dependent on monthly sales – refer to Table 1 Gross pay Sum of base pay and commission Deductions 18% of gross pay Net pay Gross pay minus deductions


Use the code below to answer the questions that follow:


public class CS204{

public static int linearSearch(int[] data, int target) {

for (int i = 0; i < data; i++) {

if (target == data[i]){

return I;


}

}

return -1;



public void main(String[] args) {

int[] data = {3, 14, 7, 22, 45, 12, 19, 42, 6};

System.out.println("Search for 7: " + linearSearch(7));

}


QUESTIONS


i. Why is method linearSearch declared static?


ii. Identify and resolve the errors in the code.

Write a C++ program that will input an employee's monthly sales and calculate the gross pay, deductions, and net pay


Question 2

A. Using the right integrity rules, explain why it is important to control how data is deleted from relational database. [10 Marks]

B. In your own words, explain why one cannot consider every table as a relation. [10 Marks]

C. All relations are in 1st Normal form. Explain.


A. Consider a problem to find the student who had the highest GPA for the 2020/2021 academic year.


i. Explain your choice of either a search or a sorting algorithm to solve this problem.


ii. Write the algorithm for your implementation.


B. Consider the analogy of a pile of books on a table. Using a diagram, explain the basic operations involved in adding a book to the pile and removing a book from the pile.


Software used in an aircraft has to be developed using a different development process as an e-commerce web page. An operating system has to be developed differently from a word processor. In large software systems different parts may be developed using different process models. Suggest and justify the most appropriate generic software process model that might be used as a basis for managing the development of the following systems:


a) An interactive system for Bus passengers that finds Bus times from terminals installed in stations

b) Smart door lock system with automation and security



please give answer ..........


Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following:

  • How to format each dictionary item as a text string in the input file.
  • How to covert each input string into a dictionary item.
  • How to format each item of your inverted dictionary as a text string in the output file.

Create an input file with your original three-or-more items and add at least three new items, for a total of at least six items.


Include the following in your Learning Journal submission: 

  • The input file for your original dictionary (with at least six items).
  • The Python program to read from a file, invert the dictionary, and write to a different file.
  • The output file for your inverted dictionary.
  • A description of how you chose to encode the original dictionary and the inverted dictionary in text files.
LATEST TUTORIALS
APPROVED BY CLIENTS