COIS 1020H - Test 2 - Fall 2021 PDF

Title COIS 1020H - Test 2 - Fall 2021
Author Dynamic Statiic
Course Programming Languages
Institution University of Ontario Institute of Technology
Pages 3
File Size 121.2 KB
File Type PDF
Total Downloads 69
Total Views 482

Summary

COIS 1020HTest 2 Fall 2021 – DurhamWeight: 10%Duration: 1 HourInstructions:This is an open book exam where you can utilize hard copy or electronic notes (using a browser is not permitted until the submission window which is the last 5 minutes of the test). You have up to one hour to complete the exa...


Description

COIS 1020H Test 2 Fall 2021 – Durham Weight: 10% Duration: 1 Hour Instructions: This is an open book exam where you can utilize hard copy or electronic notes (using a browser is not permitted until the submission window which is the last 5 minutes of the test). You have up to one hour to complete the exam. You may not communicate or collaborate with anyone in the class, however, you may ask me any clarification questions you have. Every minute past the submission window constitutes a 2-point late penalty. Submissions will not be accepted 10 minutes after the deadline.

1) [5 marks] Implement a complete program that will calculate and output (to console) the sum of all elements of type double in the sampleDoubleData array. Next, overload the method so that it can also calculate and output (to console) the sum of all elements of type int in the sampleIntData array.

sampleDoubleData = [0.0, 2.0, 6.0, 5.0, 9.0, 9.6] sampleIntData = [1, 5, 6, 8, 3] public static void Main(){ }

2) [5 marks] Construct a complete program that will utilize a loop to search for ALL instances of the number 87 in the sample data array below. Once the search is complete and all instances of the number 87 has been found your program should output the following: The number 87 has been found at indices 3 , 5 and 6.

sampleDataArray = [5, 6, 87, 21, 89, 87, 87]

3) [5 marks] Construct a class that can create a car object with the following attributes:     

Car Make (String) Car Model (String) Car Year (Int) Sales Price (Double) Sold (Boolean)

Create a default constructor for the class and a constructor that accepts all of the attributes as parameters. Next, create a class property (oftentimes referred to as an operation or a method) that checks whether the car was sold or not and outputs that to the console. Lastly, from within the Main method instantiate an instance of the car object 1- using the default constructor and 2instantiate and instance of the car object using the constructor that takes all the properties as parameters followed by using the sold method to output (to console) whether or not the car has been sold....


Similar Free PDFs