C++ Visual Studio 2019
Part A :
Program Description:
Write a program to generate a report based on input received from a text file. Suppose the input text file student_grades.txt contains the student’s Last name , First name, SSN, Test1, Test2, Test3 and Test4. (25%)
i.e.
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0
Generate the output Report File student_final.txt in the following format :
LastName FirstName SSN Test1 Test2 Test3 Test4 Average FinalGrade
i.e.
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0 78.25 .0 C+
The program must be written to use the enum letterGrade :
enum letterGrade {A_PLUS,A, A_MINUS,B_PLUS,B, B_MINUS, C_PLUS,C, C_MINUS,D_PLUS,D, D_MINUS,F } ;
Use the following function prototype for deriving letter grade :
letterGrade deriveGrade(double average) ;
The average is calculated as follows : (test1 + test2 + test3 + test4)/4.0
The function deriveGrade should derive the letterGrade of the student based on the following grading scale :
|
Letter Grade |
Percentage |
GPA |
|
A+ |
97%+ |
4.33/4.00 or 4.00/4.00 |
|
A |
93%-96% |
4.00/4.00 |
|
A- |
90%-92% |
3.67/4.00 |
|
B+ |
87%-89% |
3.33/4.00 |
|
B |
83%-86% |
3.00/4.00 |
|
B- |
80%-82% |
2.67/4.00 |
|
C+ |
77%-79% |
2.33/4.00 |
|
C |
73%-76% |
2.00/4.00 |
|
C- |
70%-72% |
1.67/4.00 |
|
D+ |
67%-69% |
1.33/4.00 |
|
D |
63%-66% |
1.00/4.00 |
|
D- |
60%-62% |
0.67/4.00 |
|
F |
0%-59% |
0.00/4.00 |
Also provide the following function :
string convertToText(letterGrade grade) ; //This function converts a letterGrade type to a string type.
Requirement :
Input text file student_grades.txt
Alfalfa Aloysius 123-45-6789 90.0 100.0 83.0 49.0 Alfred Francis 123-12-1234 97.0 96.0 97.0 48.0 Gerty Gramma 567-89-0123 80.0 60.0 40.0 44.0 Android Alexis 087-65-4321 23.0 36.0 45.0 47.0 Bumpkin Fred 456-78-9012 78.0 88.0 77.0 45.0 Rubble Betty 234-56-7890 90.0 80.0 90.0 46.0 Noshow Cecil 345-67-8901 81.0 65.0 49.0 43.0 Buff Bif 632-79-9939 20.0 30.0 40.0 50.0 Airpump Andrew 223-45-6789 75.0 90.0 100.0 83.0 Backus Jim 143-12-1234 85.0 97.0 96.0 97.0 Carnivore Art 565-89-0123 71.0 80.0 60.0 40.0 Dandy Jim 087-75-4321 92.0 23.0 36.0 45.0 Elephant Ima 456-71-9012 19.0 78.0 88.0 77.0 Franklin Benny 234-56-2890 50.0 90.0 80.0 90.0 George Boy 345-67-3901 40.0 11.0 91.0 84.0 Heffalump Harvey 632-79-9439 30.0 91.0 20.0 30.0
In: Computer Science
make a C++ program to calculate total water bill for a customer. The water company charges $250.00 for <=1000 gallons of water. Over 1000 gallons the company charges .99 / gallons
The program displays
Gallons of water used = xx
Exatra payment= xx
Total payment = xx
In: Computer Science
Write a program that does the following in order:
1. Ask user to enter a name
2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5”
3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5”
4. If the sum is greater than 0, print out the sum
5. If the sum is equal to zero, print out “Your account balance is zero”
6. If the sum is less than 0, print out “Your account is overdrawn” and the “negative amount”
7. Round all print values to 1 decimal place
Round your sum output to 2 decimal places
In: Computer Science
make a C++ program to calculate discount for a customer.
If customer code equals 1 discount = 5%
Any other code discount = 2%
Display the discount
In: Computer Science
Question 3. A string p = p1…pn is a palindrome if it spells the same string when read backward, that is pi = pn+1 –i for 1≤ i ≤ n. Design an efficient algorithm for finding all palindromes (of all lengths) in a text. (The pseudo code the algorithm should be provided) (40 points)
In: Computer Science
The stages of the classical waterfall model for software development consist of requirements, design, implementation, testing, deployment, and maintenance. Why does picturing the development of software to run on mobile applications, business-based systems, or Internet environments help to ensure the success of the development effort? What might happen otherwise? What is the professionalism with respect to software engineering? What do you do, as a software engineer involved in a software systems development project, to ensure that the product is better because of your participation in the development effort?
Answer any 3 questions
In: Computer Science
Please write in Java and have two methods: the main method and the reverse word
Write a method that reads a line and reverses the words in the line (not the characters) using a stack. For example, given the following input:
The quick brown fox jumps over the lazy dog
you should get the following output:
dog lazy the over jumps fox brown quick The
Then create a main method to prompt the user to enter a line of words to be reversed using the previous reverse method.
In: Computer Science
Describe some of the risks associated with the “bring your own device” movement and some of the policies companies have established to mitigate these risks.
Provide examples of how biases in data sets used to train artificial-intelligence systems resulted in poor performance of these systems across diverse populations.
In: Computer Science
We want to provide home-delivery service to our customers.
Select one:
a. Business Requirement
b. User/Stakeholder Requirement
c. Functional Requirement
d. Non-Functional Requirement
In: Computer Science
Consider the following IPv4 forwarding table, using CIDR. As in exercise 1, IP address bytes are in hexadecimal, and “:” is used as the separator as a reminder.
| destination | next_hop |
|---|---|
| 00:0:0:0/2 | A |
| 40:0:0:0/2 | B |
| 80:0:0:0/2 | C |
| c0:0:0:0/2 | D |
(a). To what next_hop would each of the following be routed? 63:b1:82:15, 9e:00:15:01, de:ad:be:ef
(b). Explain why every IP address is routed somewhere, even though there is no default entry. Hint: convert the first bytes to binary
In: Computer Science
Your assignment is to write a C++ program to read a text file containing the information of the employees of a company, load them into memory and perform some basic human resources operations. This assignment will help you practice: multiple file programming, classes, public and private methods, dynamic memory allocation, constructors and destructors, singly linked list and files.
Implementation
This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of the required classes. There are two classes to implement Employee and Company. #the Company will hold a linked list of Employees. This list of employees is modeled using linked nodes of Employee* (pointers to Employees). These employees are created dynamically when they are added to the list.
You will create the following files:
Class Descriptions
Employee
Notice there are no changes from previous Employee implementation
| Access | Member | Description |
|---|---|---|
| Private | _id: unsigned int | ID |
| Private | _name: string | Name |
| Private | _salary: double | Salary |
| Private | _managerId: unsigned int | Manager ID |
| Public | Employee(unsigned int, const string&, double, unsigned int=0 | Creates an employee using the values given by the parameters. The last parameter represents the manager ID. If the name parameter is an empty string, the constructor should initialize the name to “***” |
| Public | Employee(const Employee&) | Copy constructor for Employee |
| Public | GetID(): unsigned int | Accessor for ID |
| Public | GetName(): string | Accessor for name |
| Public | GetSalary():double | Accessor for salary |
| Public | GetManagerId(): unsigned int | Accessor for Manager ID |
| Public | ToString():string | Returns a string representation of the Employee. (see after the table for the details on this method) |
| Public | Raise(double):void | Gives a raise to the employee, adding the specified amount to his or her current salary. |
| Public | Equals(const Employee&) | Returns true if the employee specified by the parameter has same ID as current object. |
| Public | Read(istream&):bool | Reads an employee from the istream returning true/false depending on whether read was successful. |
| Public | Write(ostream&):void | Writes the information about an employee, separated by spaces, to the ostream. |
| Public | ~Employee() | Destructor, empty |
Company
| Access | Member | Description |
|---|---|---|
| Private | struct Node{Employee* data; Node* next; } | Represents the node type that will become each of the links of the linked list. |
| Private | _head: Node* | Head of the list, is the pointer to the first element of the list. |
| Private | _size: unsigned int | The number of actual employees in the list. In the beginning, there are no employees. |
| Private | Company(const Company&) | Copy constructor private to prevent copies from 'outside' the class. |
| Public | Company() | Constructor for Company. Sets the _size to zero, initializes _head to nullptr. |
| Public | AddEmployee(unsigned int, const string&, double, unsigned int=0): bool | Adds an employee to the list (to the correct position, the list must always be sorted). The parameters specify the information about the employee. Returns true if it was able to add it, false otherwise. |
| Public | AddEmployee(const Employee&): bool | Adds the specified employee to the list(to the correct position, the list must always be sorted). Returns true if it was able to add it, false otherwise. |
| Public | FindById(unsigned int): int | Uses binary search to find an employee using the ID given in the parameter. Returns -1 if the employee is not found. If it is found returns the position of that employee. |
| Public | FindByName(const string&, unsigned int=0) | Uses linear search starting from the position specified by the second parameter to find the first occurrence of the given name in the Array. Returns -1 if the employee is not found. If it is found returns the position of that employee. |
| Public | Read(istream&):int | Reads an istream and extracts all the employees’ data from there, and adds the employees to existing list of employees. Returns the number of employees read. |
| Public | Write(ostream&):int | Writes all the available employees to the ostream. Returns the number of employees written. |
| Public | IsFull():bool | Always returns false. |
| Public | Get(unsigned int): Employee* | Returns a pointer to the Employee at the position specified by the parameter. If the position is invalid, it returns nullptr. The referenced object belongs to the object and should not be “deleted” by the client. |
| Public | GetEmployeeCount():unsigned int | Returns the number of employees in the Company (_size) |
| Public | ~Company() | Frees the memory by releasing all the dynamically created employees in the array. |
Employee::ToString(), returns a formatted string following the following format:
ID: 1 Name: Peter Salary: 250 Manager ID: 0
Widths:
Program Menu
Your program should output the following menu:
1. Load from File 2. Save to File 3. List all Employees 4. Search by Name 5. Search by ID 6. Find Employee Boss Information 7. Add new Employee 8. Check if Database is Full 9. Exit
| Menu Option | Description |
|---|---|
| Load a Company File | Asks the user for the file name containing the employee’s information. TXT files containing sample company information are included with this Lab document. |
| Save Company Data to File | Saves the current information in memory to a file. The program asks the user for the file name where the user wants to save this. |
| List all Employees | Lists all the employees stored in memory. Uses company ToString method to display them. |
| Search by Name | The user inputs a name, then, using the method FindFirstByName the program displays all employees with that name using ToString method. |
| Search by ID | The user inputs an ID, then, using the method FindById the program displays the employee with that ID using ToString method or that it did not find that ID. |
| Find Employee Boss Information | The user inputs an ID, then, using the method FindById the program displays the employee ID using GetID method or that it did not find that ID. Once the employee is found, gets the manager’s ID, and with it searches that ID and gets the manager’s rest of the information. Displays the manager information using ToString method. |
| Add New Employee | Requests the user to enter the following information about the employee: ID, name, salary and manager ID. Manager ID is zero for employees without boss. Only adds employees if it fits in the array! Only adds employees with ID that is not already in the list |
| Check if Database is Full | Displays a message indicating if the database is full, or not full. |
| Exit | Exits the program |
In: Computer Science
Thank You
In: Computer Science
Troubleshoot the code to create a dynamic input field to take
numerical inputs and label strings to draw a pie chart.
<html>
<head>
<title>AddingRows</title>
</head>
<header>
<h1>AddingRows</h1>
</header>
<style>
table, td {
border-style:double;
border-color: black;
}
</style>
<body>
<table id="shtol">
<tr>
<td>Label 2 </td>
<td><input type="text" class = "labelIn"/></td>
<td>Percentage</td>
<td><input type="number" class = "percentIn"/></td>
</tr>
<tr>
<td>Label 1 </td>
<td><input type="text" class = "labelIn"/></td>
<td>Percentage</td>
<td><input type="number" class = "percentIn"/></td>
</tr>
</table>
<br>
<button type="button" onclick="addR()">Add Label</button>
<button type="button" onclick="drawChart()">Draw the Pie Chart</button>
<div id="chart_div"></div>
<p id = "counters" style = "display:none">2</p>
<script>
function addR() {
var counterHT = document.getElementById('counters');
var counter = counterHT.innerHTML;
counter++;
counterHT.innerHTML = counter;
var table = document.getElementById("shtol");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
cell1.innerHTML= "Label " + counter;
cell2.innerHTML = "<input type = text>";
cell2.classList.toggle("labelIn");
cell3.innerHTML = "Percentage ";
cell4.innerHTML = "<input type = text>";
cell4.classList.toggle("percentIn");
}
function drawChart(){
var data = new google.visualization.DataTable();
data.addColumn('string', 'Label');
data.addColumn('number', 'Percentage');
var x = document.getElementsByClassName("labelIn");
var y = document.getElementsByClassName("percentIn");
var i;
for(i = 0; i < x.length; i ++){
data.addRows([
[x[1].value,y[1].value]
])
}
var myTitle = document.getElementById("title").value;
// Set chart options
var options = {'title':myTitle,
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</body>
</html>
In: Computer Science
Write a function that removes all even numbers from an array. The function should take the array, length of the array, and a pointer for number of odd numbers found as arguments and return a pointer to the new array. If there are no odd numbers found in the array, your code should print "No odds found." and return NULL.
Use the function header:
int *removeEvens(int *a, int length, int *oddsFound);
Example:
Input array a[ ] = {3, 4, 5, 6, 7}
*oddsFound = 3
return array = {3, 5, 7}
The size of the return array needs to be the number of odd numbers found.
Note: You can determine if a number is even by checking if a[x] % 2 == 0.
In: Computer Science
Consider the relational schemas given below and the respective sets of functional dependencies valid in the schemas. For each one of the relational schemas identify its highest normal form. Remember that the identification of a normal form requires analysis of the valid functional dependencies and the minimal keys. Provide justification of each answer. A solution with no comprehensive justification scores no marks.
(iv) When a staff is required to undertake an inspection of
properties, the staff is allocated a company car for the day. A
staff may inspect several properties on a given date, and a
property is only inspected once on a given date. These information
of the inspection are stored in the following relational
table:
PropertyInspection(PropertyNum, IDate, ITime, Comments, StaffNum,
CarRegNum)
(vi) Each student is assigned with a counselor who will act as
an advisor to the students. The student is given the counselor
email address so that the student can contact the counselor for
advice. The information on the student and counselor are stored in
the following relational table.
STUDENTCOUNSELOR (StdNum, StdName, CounselorName,
CounselorEmail)
In: Computer Science