CSC 252
Week 4 HW
Provide code and full projects neatly and in proper form and in the correct header and cpp files. Code must compile, link and run for any credit.This is Microsoft visual Studio C++ and needs to be done correctly and neatly and I need to be able to copy and paste code to visual studio and this is for a grade so if you don't know the answer don't answer please and thank you.
Exception Handling – Chapter 16
Recursion Labs – Chapter 17
ANSWER:
#include <iostream>
#define OverdraftLimit 3500
using namespace std;
class myexception: public exception
{
virtual const char* what() const throw()
{
return "Your Withdrawal crosses the overdraft
Limit\n";
}
} withdrawal;
class Myexception: public exception
{
virtual const char* what() const throw()
{
return "Your Withdrawal crosses the overdraft
Limit\n";
}
} factorial;
////Account class
class Account
{
float balance;
public:
Account(float x)
{
balance=x;
}
void withdraw(float x)
{
try
{
if(x >balance
)
{
float temp=x-balance;
balance=0;
if(temp>OverdraftLimit) //if the withdrawal
exceed to the OverdraftLimit then throw exception
{
throw withdrawal;
}
else
{
cout<<"Your Withdrawal is Successfully Done\n";
}
}
}
catch (exception&
e) //catch the
exception
{
cout << e.what() << '\n';
}
}
};
//////factorial
int findfact(int n) //it
will return factorial of number n
{
if(n==1)return 1;
else return n*findfact(n-1);
}
void facto()
{
int fact;
cout<<"enter a number for finding
factorial : ";
cin>>fact;
//fact=10.7;
try
{
if(cin.fail()||fact<0)
//if number enter by user is negative or non-integer then throw
exception
{
throw
factorial;
}
cout<<"factorial:
"<<findfact(fact);
}
catch (exception&
e)
//catch the exception
{
cout<<"You entered
invalid number for finding factorial";
}
}
int main()
{
Account ob(5000);
float amount;
ob.withdraw(6500); //calling withdrawal function
for withdrawal
ob.withdraw(9500);
facto();
return 0;
}
CSC 252 Week 4 HW Provide code and full projects neatly and in proper form and in the correct hea...
CSC 252 Week 4 HW Provide code and full projects neatly and in proper form and in the correct header and cpp files. Code must compile, link and run for any credit.This is Microsoft visual Studio C++ and needs to be done correctly and neatly and I need to be able to copy and paste code to visual studio and this is for a grade so if you don't know the answer don't answer please and thank you. Exception Handling...
Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...
Please provide the full code...the skeleton is down below: Note: Each file must contain an int at the beginning, stating the number of records in the file. Afterwards, the number of records in the file will follow. Each record that follows will consist of a last name (String), and a gpa (double). However, to test the error handling of your program, the number of records will not always match the int value. All possible combinations should be tested. 1.) Prompt...
/************************************************************************************ * Program: PRG/420 Week 5 * Purpose: Week 5 Coding Assignment * Programmer: TYPE YOUR NAME HERE * Class: PRG/420 * Creation Date: TYPE TODAY'S DATE HERE ************************************************************************************* * Program Summary: * This program converts a given date to a string. * The code includes exception handling for a ParseException. ************************************************************************************/ package prg420week5_codingassignment; import java.util.*; // wildcard to import all the util. classes import java.text.*; // wildcard to import all the text classes public class PRG420Week5_CodingAssignment { public static...
Provide code and full projects neatly and in proper form and in the correct header and cpp files((we have to make 3 files header file , one .cpp file for function and one more main cpp file) Operator Overloading – Chapter 14 Design a class Complex for representing complex numbers and the write overloaded operators for adding, subtracting, multiplying and dividing 2 complex numbers. Also create a function that will print a complex number on the screen. Provide appropriate constructors...
Background: The purpose of this assignment is to practice dealing with exception handling and textual data. Exception handling is a very important part of being an object-oriented programming. Rather returning some kind of int return value every time you tickle an object, C++ programmers expect methods to focus on their task at hand. If something bad happens, C++ programmers expect methods to throw exceptions. When caught, exceptions can be processed. When uncaught, they cause a program to terminate dead in...
Advanced Object-Oriented Programming using
Java
Assignment 4: Exception Handling and Testing in
Java
Introduction - This assignment is
meant to introduce you to design and implementation of
exceptions in an object-oriented language. It will
also give you experience in testing an
object-oriented support class.
You will be designing and implementing a version of the game
Nim. Specifically, you will design and implement a
NimGame support class that stores all actual
information about the state of the game, and detects and throws...
Provide code and full projects neatly and in proper form and in
the correct header and cpp files((we have to make 3 files header
file , one .cpp file for function and one more main cpp file)
Template Classes – Chapter 12
Write an example of a template function that can swap 2 generic
elements.
Create a C++ class vector using the class diagram shown in
Figure 12.2. in Liangs textbook. Do not use the C++
provided header file <vector>...
This is my Final Multiple Choice section of my Final Exam Please answer ABCD and neatly please and thank you and all questions are with microsoft visual studio c++. MULTIPLE CHOICE. Choose ONLY ONE alternative that best completes the statement or answers the question. 1) Which of the following statements are correct? 1) _______ A) char charArray[2][] = {{'a', 'b'}, {'c', 'd'}}; B) char charArray[2][2] = {{'a', 'b'}, {'c', 'd'}}; C) char charArray[][] = {{'a', 'b'}, {'c', 'd'}};D) char charArray[][]...
I need help modifying this code please ASAP using C++
Here is what I missed on this code below
Here are the instructions
Here is the code
Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...