C++, Write an Exception Class for the Student class you created in the initial project you worked on. Create a try catch block that would catch negative numbers for the Student id.
// header file
#pragma once
#include<iostream>
#include<string>
constexpr auto MAX = 100;
using namespace std;
class Roster1
{
private:
string student_name;
int student_id;
int final_grade;
string letter_grade;
public:
//constroctor
Roster1();
//destroctor
~Roster1();
// setters
void setStudents(string newname, int newgade, int
newid);
void validatename(string newname);
void setstudent_name(string newname);
void setstudent_id(int newid);
void setfinal_grade(int newgrade);
void setletter_grade(int newgrade);
void validateGrade(int newgrade);
int validateID(int newid);
//getters
string getstudent_name();
int getfinal_grade();
string getletter_grade();
int getstudent_id();
//int getStudents();
//void getData();
};
// Class definition (implementation)
#include "Roster1.h"
Roster1::Roster1()
{
student_name = "";
student_id = 0;
final_grade = 0;
}
Roster1::~Roster1()
{
}
void Roster1::validateGrade(int newgrade) {
final_grade = newgrade;
if (final_grade >= 0 && final_grade <= 100);
else
cout << "Enter a Valid grade.";
}
//int Roster1::validateID(int newid) {
//}
void Roster1::validatename(string newname) {
student_name = newname;
bool beta = false;
int nameLength = student_name.length();
for (int i = 0;i < nameLength;i++)
{
if (isalpha(student_name[i]))
{
cout <<
student_name[i] << " is a letter.\n";
}
else
{
cout <<
"First instance of a non char is at index "
<<
student_name.find_first_not_of("abcdefghijklmnopqrstuvwxyz", 0)
<< ".\n";
beta =
true;
if (beta ==
true)
{
cout << "Enter a name with characters
only.\n";
cin >> student_name;
}
}
}
}
void Roster1::setStudents(string newname, int newgrade, int
newid)
{
student_name = newname;
student_id = newid;
final_grade = newgrade;
}
void Roster1::setstudent_name(string newname) {
student_name = newname;
}
void Roster1::setstudent_id(int newid) {
student_id = newid;
}
void Roster1::setfinal_grade(int newgrade) {
final_grade = newgrade;
}
void Roster1::setletter_grade(int newgrade) {
if (final_grade >= 93 && final_grade <=
100)
letter_grade = "A";
else if (final_grade >= 90 && final_grade <= 92)
letter_grade = "A-";
else if (final_grade >= 87 && final_grade <= 89)
letter_grade = "B+";
else if (final_grade >= 83 && final_grade <= 86)
letter_grade = "B";
else if (final_grade >= 80 && final_grade <= 82)
letter_grade = "B-";
else if (final_grade >= 77 && final_grade <= 79)
letter_grade = "C+";
else if (final_grade >= 73 && final_grade <= 76)
letter_grade = "C";
else if (final_grade >= 70 && final_grade <= 72)
letter_grade = "C-";
else if (final_grade >= 67 && final_grade <= 69)
letter_grade = "D+";
else if (final_grade >= 60 && final_grade <= 66)
letter_grade = "D";
else
letter_grade = "F";
}
string Roster1::getstudent_name() {
return student_name;
}
int Roster1::getfinal_grade() {
return final_grade;
}
string Roster1::getletter_grade() {
return letter_grade;
}
int Roster1::getstudent_id() {
return student_id;
}
// main
#include<iostream>
#include<string>
#include "roster1.h"
using namespace std;
int menu() {
int c;
while (true)
{
// created a menu outside of the
main, it returns the value that the user input to the main
cout << "This program will
record a student record" << endl;
cout << "1). Add the Student
Record." << endl;
cout << "2). Delete Student Record." << endl;
cout << "3). Display
Student Record." << endl;
cout << "4). Display average
grade" << endl;
cout << "5). Exit" << endl;
cout << "Please enter the choice (1 to 5):";
cin >> c;
if (c >= 1 && c <= 5)
return c;
else
continue;
}
}
int main()
{
Roster1 std[100]; // array
int choice, student_count = 0, flag = 0;
string name;
int id, grade, sum = 0;
double average = 0;
bool con = true;
while (con) // while loop
{
choice = menu(); // brings the
value from int menu and declare it to choice
switch (choice)
{
case 1:
cout << "Enter Student
name:";
cin >> name;
std[student_count].validatename(name);
cout << "Enter Student
ID:";
cin >> id;
cout << "Enter the
Grade:";
cin >> grade;
std[student_count].validateGrade(grade);
std[student_count].setletter_grade(grade);
std[student_count].setStudents(name, grade, id);
student_count++;
cout << "Student " <<
student_count + 0 << " Stored Successfully " << endl;
// display to the user the amount of student so far
break;
case 2:
cout << "Enter the student id you want to delete:";
cin >> id;
for (int i = 0;i < student_count;i++)
{
if (std[i].getstudent_id() == id)
{
//std[i].~student();
flag = 1;
cout << "Student Record deleted;" << endl;
break;
}
}
if (flag == 0)
{
cout << "Student not found!" << endl;
}
break;
case 3:
cout << "Enter the student id you want display record:";
cin >> id;
flag = 0;
for (int i = 0;i < student_count; i++)
{
if (std[i].getstudent_id() == id)
{
cout << "Student name\t:" << std[i].getstudent_name() << endl;
cout << "Student id\t:" << std[i].getstudent_id() << endl;
cout << "Student final grade\t:" << std[i].getfinal_grade() << endl;
cout << "Student Letter Grade\t:" << std[i].getletter_grade() << endl;
flag = 1;
break;
}
}
if (flag == 0)
{
cout << "Student not found!" << endl;
}
break;
case 4:
average =
0;
sum = 0;
for (int i = 0;
i < student_count;i++) {
sum = sum + std[i].getfinal_grade();
}
average =
((double)sum) / student_count;
cout <<
"average grade of the class is: " << average <<
endl;
break;
case 5:
con = false;
// makes con false to finish the program
break;
}
}
return 0;
In: Computer Science
IS-LM-BP Model (Open Economy)
Question 2
Goods Market
C = Co + cYD
YD = Y- T +TR
T = To + tY
I = Io – bi
G = Go, TR = TRo
X = Xo + λθ + γYf
M = IMo + mY – ψθ
Money Market
L = kY - hi
Ms/P = Mo/P + ΔRE/P
Foreign Exchange Market
NX = NXo – mY + vθ + γYf
CF = CFo + f (i – if)
ΔRE/P = NX + CF
Endogenous Variables: C, YD T, I, X, IM, L, Ms, CF, NX, Y, i and .RES/P
Exogenous Variables: Co, To, Io, Go, TRo, Xo, Yf, IMo, Mo, CFo, NXo, i, if and P
Parameters: c, t, b, λ, γ, ψ, m, f, k, h and v
Policy variables: Fiscal policy: (G, t and TR) Monetary policy: (Mo, P) and Exchange Rate: (θ)
1. Explain the general role of parameters λ, γ, ψ, m, f, k, h, v in the algebraic model
2. For the macroeconomic model given, identify the ER (exchange rate) system and the extent of capital mobility (perfect or imperfect) in this economy.
3. Assume that the economy is initially in internal-external equilibrium, show the effects of a devaluation of the real exchange rate (increase in θ), on interest rate i* and output Y*, in an IS-LM-BP space.
4. Provide a brief written description of the adjustment process that occurs in no. 3 above.
5. Use qualitative analysis (state direction of change, do not calculate any values) and clearly describe in words, the ultimate impact of the above policy on the equilibrium level of the following endogenous variables:
6. Explain the costs of devaluation and the ‘J Curve effect’
In: Economics
Suppose an inflationary economy can be described by the following equations representing the goods and money markets:
C = 20 + 0.7Yd
M = 0.4Yd
I = 70 – 0.1r
T = 0.1Y
G = 100 X = 20
Ld = 389 + 0.7Y – 0.6r
Ls = 145
where G represents government expenditure, M is imports, X is exports, Y is national income, Yd is disposable income, T is government taxes (net of transfer payments), I is investment, r is the rate of interest, C is consumption, Ld is money demand, and Ls is money supply.
i) Use the inverse matrix method to solve for the equilibrium level of national income and the equilibrium rate of interest in this economy. (Note: ½ of the marks in this part are given for the correct set up of the equations. Explain what you are doing, including how equilibrium is established in each market.)
ii) Now use Cramer’s rule to find your answer.
In: Economics
Revenue and cash receipts journals; accounts receivable subsidiary and general ledgers
Transactions related to revenue and cash receipts completed by Crowne Business Services Co. during the period April 2–30 are as follows:
| Apr. 2. | Issued Invoice No. 793 to Ohr Co., $5,690. | |
| Apr. 5. | Received cash from Mendez Co. for the balance owed on its account. | |
| Apr. 6. | Issued Invoice No. 794 to Pinecrest Co., $2,050. | |
| Apr. 13. | Issued Invoice No. 795 to Shilo Co., $3,050. | |
| Post revenue and collections to the accounts receivable subsidiary ledger. | ||
| Apr. 15. | Received cash from Pinecrest Co. for the balance owed on April 1. | |
| Apr. 16. | Issued Invoice No. 796 to Pinecrest Co., $6,370. Post revenue and collections to the accounts receivable subsidiary ledger. |
|
| Apr. 19. | Received cash from Ohr Co. for the balance due on invoice of April 2. | |
| Apr. 20. | Received cash from Pinecrest Co. for balance due on invoice of April 6. | |
| Apr. 22. | Issued Invoice No. 797 to Mendez Co., $8,390. | |
| Apr. 25. | Received $2,320 note receivable in partial settlement of the balance due on the Shilo Co. account. | |
| Apr. 30. | Received cash from fees earned, $14,320. Post revenue and collections to the accounts receivable subsidiary ledger. |
Required:
1. Insert the following balances in the general ledger as of April 1:
| 11 | Cash | $13,030 |
| 12 | Accounts Receivable | 15,870 |
| 14 | Notes Receivable | 6,910 |
| 41 | Fees Earned | - |
After completing the recording of the transactions in the journals in part 3, total each of the columns of the special journals, and post the individual entries and totals to the general ledger. Insert account balances after the last posting. When posting to the general ledger, post in chronological order. However, if there is more than one entry on the same date, be sure to post transactions from the revenue journal before posting transactions from the cash receipts journal.
If an amount box does not require an entry, leave it blank. In CNOW, Journal pages begin with “J”, Cash Receipts begin with “CR” and Cash Receipts begins with “R”. For example journal/ Cash Receipts/ Cash Receipts, page 1/36/40 respectively. POST. REF. is simply J1, CR36, and R40.
| GENERAL LEDGER | ||||||
|---|---|---|---|---|---|---|
| Date | Item | Post. Ref. |
Debit | Credit | Balance Dr. | Balance Cr. |
| Account: Cash # 11 | ||||||
| Apr. 1 | Balance | ✔ | ||||
| Apr. 30 | ||||||
| Account: Accounts Receivable # 12 | ||||||
| Apr. 1 | Balance | ✔ | ||||
| Apr. 25 | ||||||
| Apr. 30 | ||||||
| Apr. 30 | ||||||
| Account: Notes Receivable # 14 | ||||||
| Apr. 1 | Balance | ✔ | ||||
| Apr. 25 | ||||||
| Account: Fees Earned # 41 | ||||||
| Apr. 30 | ||||||
| Apr. 30 | ||||||
2. Insert the following balances in the accounts receivable subsidiary ledger as of April 1:
| Mendez Co. | $9,120 |
| Ohr Co. | - |
| Pinecrest Co. | 6,750 |
| Shilo Co. | - |
After completing the recording of the transactions in the journals in part 3, post to the accounts receivable subsidiary ledger in chronological order, and insert the balances at the points indicated in the narrative of transactions. Determine the balance in the customer's account before recording a cash receipt. If an amount box does not require an entry, leave it blank. In CNOW, Journal pages begin with “J”, Cash Receipts begin with “CR” and Cash Receipts begins with “R”. For example journal/ Cash Receipts/ Cash Receipts, page 1/36/40 respectively. POST. REF. is simply J1, CR36, and R40.
| ACCOUNTS RECEIVABLE SUBSIDIARY LEDGER | |||||
|---|---|---|---|---|---|
| Date | Item | Post. Ref. | Debit | Credit | Balance |
| Account: Mendez Co. | |||||
| Apr. 1 | Balance | ✔ | |||
| Account: Ohr Co. | |||||
| Account: Pinecrest Co. | |||||
| Apr. 1 | Balance | ✔ | |||
| Account: Shilo Co. | |||||
3. Prepare a single-column revenue journal (p. 40) and a cash receipts journal (p. 36). Use the following column headings for the cash receipts journal: Fees Earned Cr., Accounts Receivable Cr., and Cash Dr. The Fees Earned column is used to record cash fees.
4. Using the two special journals and the two-column general journal (p. 1), journalize the transactions for April. Post to the accounts receivable subsidiary ledger, and insert the balances at the points indicated in the narrative of transactions. Determine the balance in the customer’s account before recording a cash receipt.
5. Total each of the columns of the special journals and post the individual entries and totals to the general ledger. Insert account balances after the last posting.
If an amount box does not require an entry, leave it blank.
| REVENUE JOURNAL | PAGE 40 | |||
|---|---|---|---|---|
| Date | Invoice No. | Account Debited | Post. Ref. | Accounts Rec. Dr. Fees Earned Cr. |
| ✔ | ||||
| ✔ | ||||
| ✔ | ||||
| ✔ | ||||
| ✔ | ||||
| () () | ||||
| CASH RECEIPTS JOURNAL | PAGE 36 | ||||
|---|---|---|---|---|---|
| Date | Account Credited | Post. Ref. | Fees Earned Cr. | Accts. Rec. Cr. | Cash Dr. |
| ✔ | |||||
| ✔ | |||||
| ✔ | |||||
| ✔ | |||||
| ✔ | |||||
| () | () | () | |||
| JOURNAL | PAGE 1 | |||
|---|---|---|---|---|
| Date | Description | Post. Ref. | Debit | Credit |
6. What is the sum of the customer
balances?
$
Does the sum of the customer balances agree with the accounts
receivable controlling account in the general ledger?
7. Would an automated system omit postings to a controlling account as performed in step 5 for Accounts Receivable?
In: Accounting
The term “backup” is often used in computing to talk about making copies of data files so that they can be replaced in case of loss. But in the case of businesses, it is not just being able to replace data that should concern managers. Explain how a business backup plan needs to be much more comprehensive.
In: Computer Science
Must be written in c++
Must display comments
Write a program that will read monthly sales into a dynamically allocated array allocated array of double values.
Your program should:
- prompt the user to enter the size of the array ( that is the
number of monthly sales)
- dynamically allocate an array large enough to hold the number of
monthly sales given
by the user
- find and print the yearly sum of all the monthly sales
Note: don’t forget to deallocate memory!
Sample Run:
Enter the number of monthly sales to be input: 4
Enter the monthly sales for month 1: 1290.89
Enter the monthly sales for month 2: 905.95
Enter the monthly sales for month 3: 1567.98
Enter the monthly sales for month 4: 994.83
The total sales for the year is: $4759.65
In: Computer Science
1. Explain in words why a regulator might want to sell as many permits as firms are willing to buy at some high price in a cap-and-trade system. Then explain why the regulator might offer to buy as many permits as firms are willing to sell at some low price in a cap-and-trade system.
In: Economics
1. Describe what a grounding wire does. ( In detail)
2. Is electrostatics a contact or field force? And how do we know that?
In: Physics
A train with six 80 K cars accelerates from a station at 4 ft/sec2.
a What torsion “T” is exerted on the support structure? What torsion is applied if another train coming into the station on the opposite track decelerates at the same rate?
b A 40’ wide, 5’ deep beam with top 30’ above street level supports the tracks beyond stations. To clear traffic and to light the street, it is a hammerhead supported by a 6’ diameter, 20’ tall solid reinforced concrete column (“J”). For the trains accelerating in opposite directions, find t max and angle of twist qat z = 0 ground level, using height L= 20’. The “J” of the hammerhead, beam and taper is ginormous.
In: Civil Engineering
Our accounting firm has won the engagement to be the new federal income tax consultant for a fortune 500 company. In the course of preparing the federal income tax returns for its tax year ending December 31, 2017, we reviewed the company's federal income tax returns for recent years. Our review discovered a large error in the company's computation of its domestic production activities deduction. The error is the result of misunderstanding the law, and was repeated on all of the recent returns. We have discussed the matter briefly and informally with the client, who has indicated that they would rather not file amended returns correcting the error. The client has also indicated that it would like a written analysis of the issue, including the chances of the issue being found by the IRS on audit and of the client prevailing on the matter if it winds up in court. To prepare for the next meeting with the client on this matter, we need to determine:
In: Accounting
Consider a particle with initial velocity v? that has magnitude 12.0 m/s and is directed 60.0 degrees above the negative x axis.
A) What is the x component v? x of v? ? (Answer in m/s)
B) What is the y component v? y of v? ? (Answer in m/s)
C) Now, consider this applet. Two balls are simultaneously dropped from a height of 5.0 m.How long tg does it take for the balls to reach the ground? Use 10 m/s2 for the magnitude of the acceleration due to gravity.
In: Physics
In C++ I just need a MAIN that uses the steps and uses the functions and class given below.
Implement the BinarySearchTree ADT in a file BinarySearchTree.h exactly as shown below.
// BinarySearchTree.h
// after Mark A. Weiss, Chapter 4, Dr. Kerstin Voigt
#ifndef BINARY_SEARCH_TREE_H
#define BINARY_SEARCH_TREE_H
#include
#include
using namespace std;
template
class BinarySearchTree
{
public:
BinarySearchTree( ) : root{ nullptr }
{
}
~BinarySearchTree( )
{
makeEmpty();
}
const C & findMin( ) const
{
assert(!isEmpty());
return findMin( root )->element;
}
const C & findMax( ) const
{
assert(!isEmpty());
return findMax( root )->element;
}
bool contains( const C & x ) const
{
return contains( x, root );
}
bool isEmpty( ) const
{
return root == nullptr;
}
void printTree( ) const
{
if( isEmpty( ) )
cout << "Empty tree" << endl;
else
printTree( root );
}
void makeEmpty( )
{
makeEmpty( root );
}
void insert( const C & x )
{
insert( x, root );
}
void remove( const C & x )
{
remove( x, root );
}
private:
struct BinaryNode
{
C element;
BinaryNode* left;
BinaryNode* right;
BinaryNode( const C & theElement, BinaryNode* lt, BinaryNode* rt )
: element{ theElement }, left{ lt }, right{ rt } { }
};
BinaryNode* root;
// Internal method to insert into a subtree.
// x is the item to insert.
// t is the node that roots the subtree.
// Set the new root of the subtree.
void insert( const C & x, BinaryNode* & t )
{
if( t == nullptr )
t = new BinaryNode{ x, nullptr, nullptr };
else if( x < t->element )
insert( x, t->left );
else if( t->element < x )
insert( x, t->right );
else
; // Duplicate; do nothing
}
// Internal method to remove from a subtree.
// x is the item to remove.
// t is the node that roots the subtree.
// Set the new root of the subtree.
void remove( const C & x, BinaryNode* & t )
{
if( t == nullptr )
return; // Item not found; do nothing
if( x < t->element )
remove( x, t->left );
else if( t->element < x )
remove( x, t->right );
else if( t->left != nullptr && t->right != nullptr ) // Two children
{
t->element = findMin( t->right )->element;
remove( t->element, t->right );
}
else
{
BinaryNode* oldNode = t;
t = ( t->left != nullptr ) ? t->left : t->right;
delete oldNode;
}
}
// Internal method to find the smallest item in a subtree t.
// Return node containing the smallest item.
BinaryNode* findMin( BinaryNode* t ) const
{
if( t == nullptr )
return nullptr;
if( t->left == nullptr )
return t;
return findMin( t->left );
}
// Internal method to find the largest item in a subtree t.
// Return node containing the largest item.
BinaryNode* findMax( BinaryNode* t ) const
{
if( t != nullptr )
while( t->right != nullptr )
t = t->right;
return t;
}
// Internal method to test if an item is in a subtree.
// x is item to search for.
// t is the node that roots the subtree.
bool contains( const C & x, BinaryNode* t ) const
{
if( t == nullptr )
return false;
else if( x < t->element )
return contains( x, t->left );
else if( t->element < x )
return contains( x, t->right );
else
return true; // Match
}
void makeEmpty( BinaryNode* & t )
{
if( t != nullptr )
{
makeEmpty( t->left );
makeEmpty( t->right );
delete t;
}
t = nullptr;
}
void printTree( BinaryNode* t) const
{
if( t != nullptr )
{
printTree( t->left);
cout << t->element << " - ";
printTree( t->right);
}
}
};
#endif
:Program your own file lab07.cpp in which your main() function will test the new data structure.
public:
void printInternal()
{
print_Internal(root,0);
}
private:
void printInternal(BinaryNode* t, int offset)
{
if (t == nullptr)
return;
for(int i = 1; i <= offset; i++)
cout << "...";
cout << t->element << endl;
printInternal(t->left, offset + 1);
printInternal(t->right, offset + 1);
}
The expected result:
insert the values (stop when entering 0): 10 5 20 3 22 6 18 7 9 13 15 4 2 1 19 30 8 0 print the values: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 13 - 15 - 18 - 19 - 20 - 22 - 30 - Print the tree: 10 ...5 ......3 .........2 ............1 .........4 ......6 .........7 ............9 ...............8 ...20 ......18 .........13 ............15 .........19 ......22 .........30 remove the values (stop when entering 0): 1 11 2 12 3 13 0 print the values: 4 - 5 - 6 - 7 - 8 - 9 - 10 - 15 - 18 - 19 - 20 - 22 - 30 - Print the tree: 10 ...5 ......4 ......6 .........7 ............9 ...............8 ...20 ......18 .........15 .........19 ......22 .........30
In: Computer Science
M11 Discussion - Data Security
Data security is a concern every day for information technology professionals. Users, even information technology professionals move data from point to point on a regular basis and often this requires some form of mobility. For this discussion, please address the points listed below. If you use web sources, include the complete URL to the article.
Each student will be responsible for responding to the discussion question by Wednesday with a word count of at least 250 words.
In: Computer Science
Discuss the chemically impaired nurse/health care professional. Identify behaviors and actions that may signify chemical impairment in an employee or colleague. What risk factors result in an increased risk for chemical addiction in the nursing profession. What are your personal feelings/ experiences regarding the chemically impaired nurse/health care professional. How would your personal feelings affect your ability as a manager to address a chemically impaired employee.
In: Nursing
In: Economics