C/C++ Final Project
PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the following features:
Documentation: You must include a document, with numbers 1-15, that tell where and how these criteria were met in your program.
For design work:
CODE:-
C++ files As given in the problem:
File name: classes.h
#ifndef CLASSES_H
#define CLASSES_H
//Base class
class baseShape
{
protected:
int shapeWidth, shapeHeight;
//Public functions of the class
public:
//Class constructor
baseShape( int checkVariable, int h);
//Function to find the area of the shape
int findArea();
};
//Derived class inherited from base class baseShape
class derivedRectangle: public baseShape
{
public:
//Class constructor
derivedRectangle( int checkVariable, int h);
//derived redefinition of the function
int findArea ();
};
//Other derived class inherited from baseShape
class derivedTriangle: public baseShape{
public:
derivedTriangle( int checkVariable, int h);
//redefinition of findArea function
//function overloadin can be used here
int findArea ();
};
#endif
File Name: classes.cpp
#include "classes.h"
#include <iostream>
using namespace std;
baseShape::baseShape( int checkVariable, int h)
{
shapeWidth = checkVariable;
shapeHeight = h;
}
//Function to find the area of the shape
int baseShape:: findArea()
{
cout << "Base class area :" <<endl;
return 3;
}
derivedRectangle::derivedRectangle( int checkVariable, int h):
baseShape(checkVariable, h) { }
//derived redefinition of the function
int derivedRectangle::findArea ()
{
cout << "Derived class findArea :" <<endl;
return (shapeWidth * shapeHeight);
}
derivedTriangle :: derivedTriangle( int checkVariable, int h):baseShape(checkVariable, h) { }
//redefinition of findArea function
//function overloadin can be used here
int derivedTriangle::findArea ()
{
cout << "derivedTriangle class findArea :" <<endl;
return (shapeWidth * shapeHeight / 2);
}
File Name: Main.cpp
//Include the header fileData
#include <iostream>
#include <iomanip>
#include <fstream>
#include "classes.h"
//Using the namespaces
using std::setw;
using namespace std;
void userInteract ();
void pointerTest();
void selection();
void switchCase();
void ArrayElements();
void fileOPerations();
//Function to swap using pass by refference
void swapPassByReference(int first, int second)
{
int *temp;
temp = first;
first = second;
second = temp;
}
//function uses a pointer
void pointerTest()
{
int intVar;
cout << "\n\nAddress of intVar variable: ";
cout << &intVar << endl;
}
void userInteract(){
float input1, input2, p;
cout << "Please Input two numbers: ";
cin >> input1 >> input2;
p = input1*input2;
cout << "Product of your inputs is = " << p;
}
//To use selection statements
void selection()
{
int checkVariable = 100;
if( checkVariable < 20 )
{
cout << "checkVariable is less than 20;" << endl;
}
else
{
cout << "checkVariable is not less than 20;" << endl;
}
cout << "value of checkVariable is : " << checkVariable << endl;
}
//To use array
void ArrayElements()
{
//declare the array
int n[10];
//The for loops
for ( int itr = 0; itr < 10; itr++ )
{
n[itr] = itr + 100;
}
cout << "Element" << setw(13) << "Value is" << endl;
for ( int vi = 0; vi < 10; vi++ )
{
cout << setw( 7 )<< vi << setw( 13 ) << n[ vi ] << endl;
}
}
//Switch for select
void switchCase()
{
char mark = 'D';
switch(mark)
{
case 'A' :
cout << "Excellent!" << endl;
break;
case 'B' :
case 'C' :
cout << "Well done" << endl;
break;
case 'D' :
cout << "You passed" << endl;
break;
case 'F' :
cout << "Failed" << endl;
break;
default :
cout << "Invalid mark" << endl;
}
cout << "Your mark is " << mark << endl;
}
//Read the fileData
void fileOPerations() {
char fileData[100];
ofstream filewrite;
filewrite.open("file.txt");
cout << "File write" << endl;
cout << "Please input your name: ";
cin.getline(fileData, 100);
cin.getline(fileData, 100);
filewrite << fileData << endl;
cout << "Please input your age: ";
cin >> fileData;
cin.ignore();
filewrite << fileData << endl;
filewrite.close();
ifstream infile;
infile.open("file.txt");
cout << "File read" << endl;
infile >> fileData;
cout << fileData << endl;
infile >> fileData;
cout << fileData << endl;
infile.close();
}
//main function
int main() {
int a = 100;
int b = 200;
userInteract();
pointerTest();
//swapPassByReference(&a, &b);
cout<<"Now a ="<<a<<"and b = "<<b<<endl;
selection();
switchCase();
fileOPerations();
//baseShape baseShape(0, 0));
derivedRectangle rec(10,7);
derivedTriangle tri(10,5);
cout<<rec.findArea();
//baseShape = rec;
//baseShape.findArea();
//baseShape = tri;
cout<<tri.findArea();
//cout<<baseShape.findArea();
return 0;
}
SAMPLE RUN :

C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the...
Your C++ project relate to the dynamic programming to solve the calculating Fibonacci numbers should demonstrate: Header files Abstract Class Subclasses Virtual function (in addition to the pure virtual function) Inheritance Polymorphism Pointers Static variables Static functions Exceptions Templates File I/O Overloaded << or >> operator Overloaded operators (at least one additional) Extra points for: Recursion Linked lists / Stacks / Queues Binary search trees Binary File with random access A friend function not related to the << and >>...
Write a C++ program that does the following : Define a class myInt that has as its single attribute an integer variable and that contains member functions for determining the following information for an object of type myInt: A. Is it multiple of 7 , 11 , or 13. B. Is the sum of its digits odd or even. C. What is the square root value. D.Is it a prime number. E. Is it a perfect number ( The sum...
(C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...
I tried to complete a Java application that must include at a minimum: Three classes minimum At least one class must use inheritance At least one class must be abstract JavaFX front end – as you will see, JavaFX will allow you to create a GUI user interface. The User Interface must respond to events. If your application requires a data backend, you can choose to use a database or to use text files. Error handling - The application should...
The Course Project can be started in Week 7 and is due by 11:59
pm CT Saturday of Week 8. It must follow standard code formatting
and have a comment block at the top of the code file with a
detailed description of what the program does. Functions must have
a comment block with a detailed description of what it does.
Pseudocode must be provided in the comment block at the top of the
file. This program will allow the...
This project involves writing a program with functionality of your choosing. You must include the programming elements as described below and must adhere to the general requirements below. Programming elements: The code must contain the following elements: (You may complete one program containing all of these elements or you may submit more than one program where all program together contain the following elements.) Classes (at least 3) Instance Fields and Methods Constructors Overloaded Method/Constructor (at least one) Arrays / ArrayLists...
General Requirements . . . Write a program that reads letters from a file called "letters.txt". Your program will open the letters.txt file read in one character at a time For this assignment the test file will contain at least 30 letters, uppercase OR lowercase In your program you will change each letter (solution) to uppercase Use the function toupper in #include <ctype.h> You create a numerical version of the uppercase letter from the file . o Use int numberSolution...
In C++ please! Please include .cpp and .hpp files! Thank you! Recursive Functions Goals Create and use recursive functions In this lab, we will write a program that uses three recursive functions. Requirements: Important: You must use the array for this lab, no vectors allowed. First Recursive Function Write a function that recursively prints a string in reverse. The function has ONLY one parameter of type string. It prints the reversed character to the screen followed by a newline character....
Please show it in C++. Thank you!
Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...