Question

In: Computer Science

i have attached my code here and we are supposed to create two classes. one is...

i have attached my code here and we are supposed to create two classes. one is date the other switches accounts for bank and then displays the bank account,type,name,date(pulled from first class and then prints out. i am having issues getting my code to pull from the first class and dont know how to make it read the data from date class if someone can look at my code and tell me how to fix this i would greatly appreciate it. Thank you!

include <iostream>
#include <string>
using namespace std;
#ifndef date_H
#define Date_H // dont know if need these two

class Date
{
private:
   int month, day, year;

public:
   //These are consturctors
   Date();// programmer defined default constructor without parameters
   Date(int, int, int);
   //Destructor
   ~Date() {}// destroy the data put into this time for new one
  
   void setDay(int); // set the day(mutator) not returning anything
   void setMonth(int);// set the month(mutator)not returning anything
   void setYear(int);// set the year(mutator)not returning anything
   void DisplDate();// displays the date which passed to class 2 Accounts
};
#endif// or this

Date::Date()// initialize the default constructor holding no parameters
{
   //Initialize variables.
   month = day = year = 0;// default values all set to 0
  
}//not returning anything
Date::Date(int Month, int Day, int Year)// default constructor hold 3 ints
{
   month = Month;
   day = Day;
   year = Year;
}//not returning anything
void Date::setDay(int d)
{
   cout<< "enter the day of your last payment"<< endl;
   cin >> day;

}//not returning anything
void Date::setMonth(int m)// need this between 1 and 12 for months
{
   cout << " enter the month of your last payment" << endl;
   cin >> month;
}//not returning anything
void Date::setYear(int y)
{
   cout << "enter a year number" << endl;
   cin >> year;
}
void Date::DisplDate()// display out the month day and year
{
   cout << month << " /" << day << " /" << year << endl;
}//not returning anything but holds the valid input data

class Account: private Date // calling the private date values relationship
{
private:
       int ActNum;// account number is integers i.e (1234567890)
       char ACCT_TYPE, Name[20];// checking, savings and user name
       Date defaultdate;
       //object of class date
       float ActBal;// must be float dealing with decimals
      
public://default parameterized constructor
   Account(int AccountNum, string Name, char ActType, float balance, Date day, Date month, Date year)
   {
       ActNum = AccountNum;
       string ActName = Name;
       char ACCT_Type = ActType;
       float ActBal =balance;
       defaultdate.day = 0;
       defaultdate.month = 00;
       defaultdate.year = 0000;// how to call this from first
   }
   void AccountData();   // idk if date goes in here
   void Accountdeposit();
   void Accountwithdrawl();
   void Accounttransfer();
   void Accountdisplay();
   //~Account() {};

};
void Account::AccountData(void)
{
   cout << "\nEnter account number : ";
   cin >> ActNum;
   cout << "\nEnter account type (c/s) : ";
   cin >> ACCT_TYPE;
   cout << "\nEnter name : ";
   cin >> Name;
   getchar();
   cout << "\nEnter balance : ";
   cin >> ActBal;
   cout << "\nEnter date of last transaction : ";
   cout << "\n Day : ";
   cin >>day;
   cout << "\n Month : ";
   cin >> month;
   cout << "\n Year : ";
   cin >> year;
}
void Account::Accountdeposit() //depositing an amount
{
   int DepositAmt;
   cout << "\n Enter Deposit Amount = ";
   cin >> DepositAmt;
   cout << " enter the account to be deposited into" << endl;
   cin >> ACCT_TYPE;
   ActBal += DepositAmt;
}

void Account::Accountwithdrawl() //withdrawing an amount
{
   int WithdrwlAmt;
   cout << "\n enter ammount to withdraw = ";
   cin >> WithdrwlAmt;
   cout << " which account do you want to be withdrawn from?" << endl;
   cin >> ACCT_TYPE;
   if (WithdrwlAmt > ActBal)
       cout << "\n Exceeds balance ammount to withdraw";
   else
       ACCT_TYPE=ActBal -= WithdrwlAmt;// the account balance of said act is
}
void Account::Accountdisplay()
{
   cout << "\n ----------------------";
   date;
   cout << "\n Accout No. : " << ActNum;
   cout << "\n Name : " << Name;
   cout << "\n Account Type : " << ACCT_TYPE;// checking and savings
   cout << "\n Balance : " << ActBal;
}

void Account::Accounttransfer()
{
  
   char ACCT_TYPE;
   double Savings, Checking, ammount;// ammount to transfer
  
   //cin >> selection;
   cout << " enter the ammount to transfer" << endl;
   cin >> ammount;
   cout << " select whihc account to transfer from and to" <<
       "checking or savings as an s or c" << endl;
   cin >> ACCT_TYPE;
   if (ACCT_TYPE == Savings)
   {
       if (Savings > 0.00)
       {
           Savings -= ammount;
           Checking += ammount;

       }
       else
           cout << "error not enough money" << endl;
  
   if (ACCT_TYPE==Checking )
       {
           if (Checking > 0.00)
           {
               Checking -= ammount;
               Savings += ammount;
           }

           else
               cout << " error not enough money" << endl;
           }
       }

   }

int main()
{   //so far below prints out data for date
   int Month, Day, Year;
  
   cout << "please enter month day and year in numerical values" <<
       "then press enter " << endl;
   cin >> Month >>Day >>Year;
   //now that the user inputted data, goes to class and evaluate for new
   //date other than default
   Date newDate(Month, Day, Year);// call to date class
   cout << " the date of your last payment was" << endl;
   newDate.DisplDate();// maybe as showpoint? without this nothing prints out
   cin.get();// getting the data from the class for the new date
   cout<< " your last payment was made on" << cin.get();// getting the data to display function
   return 0;
}

Solutions

Expert Solution

#include<bits/stdc++.h>
using namespace std;


/* I would have helped you implement all the functionality of the programm

But as you have just asked me to help you set the values from the Account class into the Date
class I have pretty much did it,


Inorder to set the values into the date Obj you can use you setters to set their values,
   and similary to use the values some palces you can make use of the getters;

   you can get rid of this function AccountData and take the input in the main and there try to create the object of the
   customers and you can strore them in some data structure to use it later;

   //You have not provided the complete statement soo as far i have understood i have suggested you some stuffs below

       // if your trying to fetch the details just on basis of certain date it make no sense as there would be number of transactions that can happen
           at the same time, so you rather try accessing the details using [Unique Account Number] and there in which you can access the date

           thank you,


   //next time make sure to briefly describe what exactly your programm is doing,

*/

class Date
{
   private:
       int month, day, year;

   public:
//These are consturctors
Date();// programmer defined default constructor without parameters
Date(int Month, int Day, int Year);
//Destructor
// destroy the data put into this time for new one

void setDay(int); // set the day(mutator) not returning anything
void setMonth(int);// set the month(mutator)not returning anything
void setYear(int);// set the year(mutator)not returning anything
void DisplDate();// displays the date which passed to class 2 Accounts

int getDay(){
       return this->day;
   };

   int getMonth(){
       return this->month;
   }

   int getYear(){
       return this->year;
   }

~Date() {}
};


Date :: Date() {
   month = day = year = 0;
}

Date::Date(int Month, int Day, int Year)// default constructor hold 3 ints
{
month = Month;
day = Day;
year = Year;
}

void Date::setDay(int d)
{
cout<< "enter the day of your last payment"<< endl;
cin >> day;

}


void Date::setMonth(int m)// need this between 1 and 12 for months
{
cout << " enter the month of your last payment" << endl;
cin >> month;
}


void Date::setYear(int y)
{
cout << "enter a year number" << endl;
cin >> year;
}

void Date::DisplDate()// display out the month day and year
{
cout << month << " /" << day << " /" << year << endl;
}

class Account: private Date // calling the private date values relationship
{


   //You need to store the data inorder to access them
private:
int ActNum;// account number is integers i.e (1234567890)
char ACCT_TYPE;
string Name;// checking, savings and user name
Date defaultdate;
//object of class date
float ActBal;// must be float dealing with decimals

public://default parameterized constructor

   Account(int accountNum, string accountHolderName, char accountType, float accountBal, int Month = 0, int Day = 0, int Year = 0)
{
           ActNum = accountNum;
           Name = accountHolderName;
           ACCT_TYPE = accountType;
           ActBal = accountBal;
           defaultdate.setMonth(Month);
           defaultdate.setDay(Day);
           defaultdate.setYear(Year);
}

void AccountData(); // idk if date goes in here
void Accountdeposit();
void Accountwithdrawl();
void Accounttransfer();
void Accountdisplay();
//~Account() {};
};


void Account::AccountData(void)
{

cout << "\nEnter account number : ";
cin >> ActNum;
cout << "\nEnter account type (c/s) : ";
cin >> ACCT_TYPE;
cout << "\nEnter name : ";
cin >> Name;
getchar();
cout << "\nEnter balance : ";
cin >> ActBal;
cout << "\nEnter date of last transaction : ";
cout << "\n Day : ";


   int transactionDay, transactionMonth, transactionYear;

cin >> transactionDay; //As you have declared them private you cannot assigned them values from different class, for which you have to make use of getters and setters || or you try changing the day, month, and year in Date to pubic;
cout << "\n Month : ";
cin >> transactionMonth;
cout << "\n Year : ";
cin >> transactionYear;
}

void Account::Accountdeposit() //depositing an amount
{
int DepositAmt;
cout << "\n Enter Deposit Amount = ";
cin >> DepositAmt;
cout << " enter the account to be deposited into" << endl;
cin >> ACCT_TYPE;
ActBal += DepositAmt;
}

void Account::Accountwithdrawl() //withdrawing an amount
{
int WithdrwlAmt;
cout << "\n enter ammount to withdraw = ";
cin >> WithdrwlAmt;
cout << " which account do you want to be withdrawn from?" << endl;
cin >> ACCT_TYPE;
if (WithdrwlAmt > ActBal)
cout << "\n Exceeds balance ammount to withdraw";
else
ACCT_TYPE=ActBal -= WithdrwlAmt;// the account balance of said act is
}
void Account::Accountdisplay()
{
cout << "\n ----------------------";
   cout << defaultdate.getDay() << ' ' << defaultdate.getMonth() << ' ' << defaultdate.getYear() << endl;
cout << "\n Accout No. : " << ActNum;
cout << "\n Name : " << Name;
cout << "\n Account Type : " << ACCT_TYPE;// checking and savings
cout << "\n Balance : " << ActBal;
}

void Account::Accounttransfer()
{

//char ACCT_TYPE; dont use the same variable what you have declared inside the class again and again

char accontType;
double Savings, Checking, ammount;// ammount to transfer

//cin >> selection;
cout << " enter the ammount to transfer" << endl;
cin >> ammount;
cout << " select whihc account to transfer from and to" <<
"checking or savings as an s or c" << endl;
cin >> accontType;


if (accontType == Savings)
{
if (Savings > 0.00)
{
Savings -= ammount;
Checking += ammount;

}
else
cout << "error not enough money" << endl;

if (accontType==Checking )
{
if (Checking > 0.00)
{
Checking -= ammount;
Savings += ammount;
}

else
cout << " error not enough money" << endl;
}
}

}

int main()
{ //so far below prints out data for date
int Month, Day, Year;

cout << "please enter month day and year in numerical values then press enter " << endl;
cin >> Month >>Day >>Year;
//now that the user inputted data, goes to class and evaluate for new
//date other than default
Date newDate(Month, Day, Year);// call to date class
cout << " the date of your last payment was" << endl;
newDate.DisplDate();// maybe as showpoint? without this nothing prints out
cin.get();// getting the data from the class for the new date
cout<< " your last payment was made on" << cin.get();// getting the data to display function
return 0;
}


Related Solutions

I'm getting an error with my code on my EvenDemo class. I am supposed to have...
I'm getting an error with my code on my EvenDemo class. I am supposed to have two classes, Event and Event Demo. Below is my code.  What is a better way for me to write this? //******************************************************** // Event Class code //******************************************************** package java1; import java.util.Scanner; public class Event {    public final static double lowerPricePerGuest = 32.00;    public final static double higherPricePerGuest = 35.00;    public final static int cutOffValue = 50;    public boolean largeEvent;    private String...
I have 3 classes in the same package called Product, Products and ProductCart. Here are my...
I have 3 classes in the same package called Product, Products and ProductCart. Here are my codes-> Product public class Product { //instance variables private int id; private String name; private double price; private int quantity; //constructor public Product(int id, String name, double price, int quantity) { this.id = id; this.name = name; this.price = price; this.quantity = quantity; } //all setters and getters public int getId() { return id; } public void setId(int id) { this.id = id; }...
The programming language that is being used here is JAVA, below I have my code that...
The programming language that is being used here is JAVA, below I have my code that is supposed to fulfill the TO-DO's of each segment. This code in particular has not passed 3 specific tests. Below the code, the tests that failed will be written in bold with what was expected and what was outputted. Please correct the mistakes that I seem to be making if you can. Thank you kindly. OverView: For this project, you will develop a game...
I am trying to create my own doubly linkedlist class and here is what I have...
I am trying to create my own doubly linkedlist class and here is what I have so far. my addfirst is adding elements forever and ever, and I could use some help. This is in C++. Please help me complete my doubly linkedlist class. the addfirst method is what I would like to complete. #ifndef DLLIST_H #define DLLIST_H #include "node.h" #include using namespace std; template class DLList { private:     Node* head = nullptr;     Node* tail = nullptr;    ...
I'm having a very hard time getting this c++ code to work. I have attached my...
I'm having a very hard time getting this c++ code to work. I have attached my code and the instructions. CODE: #include using namespace std; void printWelcome(string movieName, string rating, int startHour, int startMinute, char ampm); //menu function //constants const double TICKET_PRICE = 9.95; const double TAX_RATE = 0.095; const bool AVAILABLE = true; const bool UNAVAILABLE = false; int subTotal,taxAdded, totalCost; // bool checkAvailability( int tickets, int& seatingLeft){ //checks ticket availability while(tickets > 0 || tickets <= 200) //valid...
Here is my fibonacci code using pthreads. When I run the code, I am asked for...
Here is my fibonacci code using pthreads. When I run the code, I am asked for a number; however, when I enter in a number, I get my error message of "invalid character." ALSO, if I enter "55" as a number, my code automatically terminates to 0. I copied my code below. PLEASE HELP WITH THE ERROR!!! #include #include #include #include #include int shared_data[10000]; void *fibonacci_thread(void* params); void parent(int* numbers); int main() {    int numbers = 0; //user input....
in java: In my code at have my last two methods that I cannot exactly figure...
in java: In my code at have my last two methods that I cannot exactly figure out how to execute. I have too convert a Roman number to its decimal form for the case 3 switch. The two methods I cannot figure out are the public static int valueOf(int numeral) and public static int convertRomanNumber(int total, int length, String numeral). This is what my code looks like so far: public static void main(String[] args) { // TODO Auto-generated method stub...
I have a code and it works and runs as it supposed too. What is the...
I have a code and it works and runs as it supposed too. What is the UML for it? Any help will be awesome. Thanks. import java.util.Scanner; public class StringToMorseCode { public static void main(String[] args){ Scanner input = new Scanner(System.in);    char[] letters = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6',...
In Python I have a code: here's my problem, and below it is my code. Below...
In Python I have a code: here's my problem, and below it is my code. Below that is the error I received. Please assist. Complete the swapCaps() function to change all lowercase letters in string to uppercase letters and all uppercase letters to lowercase letters. Anything else remains the same. Examples: swapCaps( 'Hope you are all enjoying October' ) returns 'hOPE YOU ARE ALL ENJOYING oCTOBER' swapCaps( 'i hope my caps lock does not get stuck on' ) returns 'I...
Here is my java code. It works and has the correct output, but I need to...
Here is my java code. It works and has the correct output, but I need to add a file and I am not sure how. I cannot use the FileNotFoundException. Please help! import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Exercise { public static void main(String[] args) { Scanner input=new Scanner(System.in); int[] WordsCharsLetters = {0,0,0}; while(input.hasNext()) { String sentence=input.nextLine(); if(sentence!=null&&sentence.length()>0){ WordsCharsLetters[0] += calculateAndPrintChars(sentence)[0]; WordsCharsLetters[1] += calculateAndPrintChars(sentence)[1]; WordsCharsLetters[2] += calculateAndPrintChars(sentence)[2]; } else break; } input.close(); System.out.println("Words: " + WordsCharsLetters[0]); System.out.println("Characters: "...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT