This project will be an exercise in using all that we have covered in these past two weeks: Arrays (one and multidimensional arrays), branching, and input and output files.
Components:
A class called YourLastNameGradebook (Yes, YourLastName IS your last name!!!)
And an external class called SomeNeatExternalSoundingName. This external class will have at least 2 methods: readData and writeData
This project will include
The class with the main method and the other useful methods that will 1) display the arrays, 2) find the averages and store them, 3) find the grades and store them, 4) and display a chart of the final array results to the terminal window.
The external class will 1) read from the input file and 2) write to an output file.
YourLastNameGradebook class's main method will be made up of declarations and method calls. There should be no other code in the main method. (Except for one single print statement stating that the program is finished!)
Declarations:
Actions needed: Note - Do use the size
of the array for your for loops, notthe value
5.
1) Read in (Invoke the readData method in the external class ):
The input file looks like this: project2IN.txt
Leia Organa 98.0 95.5 100.0
Fred Flintstone 65.0 74.5 76.25
Sheldon Cooper 100.0 100.0 99.0
Stan Marsh 89.0 84.0 80.5
Lisa Simpson 93.0 94.5 92.0
When you open the input file, echo this to the terminal window.
The array of names will be read in from the input file. (The
names will be read in as first last but need to be rearranged to
last, first when being read in)
This array of scores will be read in from the input file.
The last element in the scores array will have a zero in it. This will be reserved for the averages (later).
When you close the input file, echo this to the terminal window.
After reading in the data: Row zero from the
names array corresponds to row zero from the
scores array:
names array contains 5 names:
element: Contents:
|
0 |
Organa, Leia |
|
1 |
Flintstone, Fred |
|
2 |
Cooper, Sheldon |
|
3 |
Marsh, Stan |
|
4 |
Simpson, Lisa |
Scores array contains 5 rows of 4 elements each
|
row |
column 0 |
column 1 |
column 2 |
column 3 |
||
|
0 |
98.0 |
95.5 |
100.0 |
|||
|
1 |
65.0 |
74.5 |
76.25 |
|||
|
2 |
100.0 |
100.0 |
99.0 |
|||
|
3 |
89.0 |
84.0 |
80.5 |
|||
|
4 |
93.0 |
94.5 |
92.0 |
|||
2) In YourLastNameGradebook class, invoke the method to display the data using a displayData method:
Display the data (using a displayData method) in the terminal window as it is stored in both of the arrays.
Data read in:
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
last, first: score1, score2, score3
(Formatting at this point is not important. Include at least one space! This is just echoing what was entered!)
3) Invoke a method that will compute the average in the scores array
4) Invoke a method that will compute the grade for each student
For each student, determine the average score from the three grades and the grade of A, B, C, D, or F
5) Invoke another displayData method that will print out the names, scores, and grades for each student in the terminal window.
6) Invoke the method in the External class that will write the clean chart to the output file project2OUT.txt
7) When done, the last statement of the main is to be an output statement telling the user that the program is finished.
Output is to be neat and clean. Use blank
spaces for readability in both the output file and in the terminal
window.
Upload (to one of your pairs’ Canvas account) ALL the files that
are needed for grading including BOTH .java files and both .txt
files:
Extra Credit:
1) Use printf to create a neat chart with a chart title (centered
above the output) and headers for the data similar to the
following. (2 points)
==========================================================================
Student Grades
Name Score1
Score2
Score3
Average
Grade
==========================================================================
Organa, Leia
98.00
95.50 100.00
.00
x
Flintstone, Fred 65.00
74.50
76.25 .00
x
and so on...
2) Insert a first new line into your input file. Alter this first line to include an integer value to represent the number of rows to be read in as a reference that will declare the sizes of the arrays to be of that size.
(2 points)
Be SURE that both names appear in the beginning
comments! Otherwise only one of you will get
credit.
This is what will be displayed to the terminal
window: This could be cleaned up to be more
readable.
Reading from input file: project2IN.txt
Closing input file: project2IN.txt
Displaying data as stored:
Organa, Leia 98.0 95.5 100.0 0.0
Flintstone, Fred 65.0 74.5 76.25 0.0
Cooper, Sheldon 100.0 100.0 99.0 0.0
Marsh, Stan 89.0 84.0 80.5 0.0
Simpson, Lisa 93.0 94.5 92.0 0.0
Computing Averages...
Average for Organa, Leia is 97.83333333333333
Average for Flintstone, Fred is 71.91666666666667
Average for Cooper, Sheldon is 99.66666666666667
Average for Marsh, Stan is 84.5
Average for Simpson, Lisa is 93.16666666666667
=================================================================
Name Score1 Score2 Score3 Average Grade
=================================================================
Organa, Leia 98.00 95.50 100.00 97.83 A
Flintstone, Fred 65.00 74.50 76.25 71.92 C
Cooper, Sheldon 100.00 100.00 99.00 99.67 A
Marsh, Stan 89.00 84.00 80.50 84.50 B
Simpson, Lisa 93.00 94.50 92.00 93.17 A
Opening the output file: project2OUT.txt
Writing data to the output file.
Closing the output file project2OUT.txt
This program is now terminating. Have a nice day.
Output file: project2OUT.txt
=================================================================
Name Score1 Score2 Score3 Average Grade
=================================================================
Organa, Leia 98.00 95.50 100.00 97.83 A
Flintstone, Fred 65.00 74.50 76.25 71.92 C
Cooper, Sheldon 100.00 100.00 99.00 99.67 A
Marsh, Stan 89.00 84.00 80.50 84.50 B
Simpson, Lisa 93.00 94.50 92.00 93.17 A
In: Computer Science
Compare and contrast the numerous advantages and disadvantages of using a DDBMS.
Describe the optimal situations of when to use a DDBMS and why.
Include the CAP Theorem and BASE in your paper and analyze their importance.
Be sure to integrate an analysis of the mobile wireless revolution, smartphones, tablets, etc. with a focus on social media related to the use of a DDBMS.
PLEASE DO NOT HAND WRITE THE ANSWER!! PLEASE ANSER THE QUESTION THOROUGHLY!! IF YOU CANNOT PROVIDE 1,000 WORDS DO NOT ANSWER THE QUESTION!!
In: Computer Science
For an implementation of kNN classification from scratch in python I am not sure if I correctly calculate the euclidian distance. Help with python code.
import pandas as pd
import numpy as np
import math
import operator
from collections import Counter
class KNN:
def calculate_distance(x1, x2, length):
e_distance = 0
for x in range(length):
e_distance += pow((x1[x] - x2[x]),2)
return math.sqrt(e_distance)
def __init__(self, k=5, p=2):
self.k = k
In: Computer Science
Assignment 2 – Data Types
Research and find the best corresponding Data Types for the following Microsoft Access Data Types from the Micosoft SQL server as well as MySQL DBMS packages.
MS Access MS SQL Server MySQL
Shorttext
Longgtext
Number (Byte)
Number (Integer)
Number (Long Integer)
Number (Decimal)
Number (Double)
Date/Time
Currency
Yes/No
In: Computer Science
You are required to write a program to provide the statistics of a file (Number of letters, number of words, number of vowels, number of special characters and number of digits.
You should implement this problem as a class and call it FileContentStats which provides statistics about the number of letters, number of words, number of vowels, number of special characters, number of lines and number of digits. All of these should be private data members.
(Should be in C++ language)
In: Computer Science
Write a function cube_all_lc(values) that takes as input a list of numbers called values, and that uses a list comprehension to create and return a list containing the cubes of the numbers in values (i.e., the numbers raised to the third power). This version of the function may not use recursion.
In: Computer Science
Write a complete Java program to create three types of counters as follows:
Please follow these notes:
In: Computer Science
Write a 'C' program to calculate the surface area of the cone and by using that, also calculate the volume of the cone and print the values as surface area of the cone and volume of the cone.
where as:
surface area of the cone = πr2 (r is the radius of the surface)
volume of the cone = (1/3)πr2h (h is the height of the cone)
In: Computer Science
void doSomething(int num)
Which of the following would be valid ways to invoke this
method?
答案选项组
System.out.println(doSomething(5));
doSomething("word".length());
doSomething(4);
doSomething(int);
doSomething(4.0);
doSomething(Math.random());
doSomething(7 + 5);
int answer = doSomething(5);
double result = doSometing(23);
doSomething((int)Math.PI);
In: Computer Science
In: Computer Science
I want to know how the application domain is formulated as a CSP(Constraint Satisfaction Problem)?
Thanks~
In: Computer Science
Java
Supermegastaurants have overtaken megastaurants as the latest trend in dining. A supermegastaurant is characterized by enormous menus, four categories of food, and a rule that you must choose exactly one item from each category. You have won a gift certificate of M dollars to use at a megastaurant. In order to maximize your dining value, you wish to choose an item from each category such that the price is as close to M as possible.
Input Format
Input begins with five integers, A, B, C, D, and M, subject to the following constraints:
1 <= A, B, C, D <=
2000
1 <= M <= 2,147,000,000
Next is a line with A positive integers, each less or equal to than 2,147,000,000. These integers are the prices of items in the first category.
Next is a line with B positive integers, each less or equal to than 2,147,000,000. These integers are the prices of items in the second category.
Next is a line with C positive integers, each less or equal to than 2,147,000,000. These integers are the prices of items in the third category.
Next is a line with D positive integers, each less or equal to than 2,147,000,000. These integers are the prices of items in the fourth category.
Output Format
You are to output the total cost of the meal with a price closest to M.
Note: This cost can be equal to M, greater than M, or less than M. In the case of a tie costs, choose the cheaper of the two costs.
Sample Input
3 2 1 2 50
15 10 49
11 17
10
13 23
Sample Output
50
Explanation
Here you can choose items that exactly equal M:
10 + 17 + 10 + 13 = 50
1) An argument of the correctness of your code:
a) State a loop invariant.
b) Argue that the loop invariant is true before the loop starts executing.
c) Argue that the loop invariant remains true after each iteration of the loop.
d) Argue for the correctness of your algorithm based on the loop invariant.
In: Computer Science
Modern CPU architectures allow for two modes of operation. Explain what the goal of having these two modes is/are, and explain how two-mode operation is used to achieve this goal(s).
In: Computer Science
Python program that simulates playing a game where a US penny (radius of 3/8 inches) is tossed into a board with a 1-inch by 1-inch square. The player wins only if the penny lands entirely within the square. Estimate the probability of winning by repeating the game 1,000 times. Record the estimate of the winning chance as a comment. Also, find the winning probability.
Please use comments to better explain :)
In: Computer Science
Write a Java program/method that takes a LinkedList and returns a new LinkedList with the integer values squared and reversed. Example: if the LinkedList has (9, 5,4,6), then the returned list will have (36, 16,25,81). What is the time-complexity of your code? You must use listIterator for full credit.
public LinkedList getReverseSquaredList (LinkedList list) { }
In: Computer Science