c++ My max is 5$

profileBebo23
codeee.zip

codeee/Menu code.txt

//System Libraries #include <iostream> //Input - Output Library #include "Prime.h" #include "Primes.h" using namespace std; //Name-space under which system libraries exist //User Libraries //Global Constants //Function Prototypes void menu(void); void prob1(void); void prob2(void); void prob3(void); void prob4(void); void prob5(void); void prob6(void); void prob7(void); //Execution begins here int main(int argc, char** argv) { //Declare variables char choice; //Show menu and loop do{ //Display Menu menu(); //Input the choice cout<<"Problem "; cin>>choice; //Place solutions to problems in switch statement switch(choice){ case '1': prob1();break; case '2': prob2();break; case '3': prob3();break; case '4': prob4();break; case '5': prob5();break; case '6': prob6();break; case '7': prob7();break; default:{ cout<<"Exit the program"<<endl; } } }while(choice>='1'&&choice<='9'); //Exit stage right! return 0; } void prob7(void){ } void prob6(void){ } void prob5(void){ } void prob4(void){ } void prob3(void){ } void prob2(void){ } void prob1(void) { } void menu(void){ cout<<endl<<endl<<"Type 0 to exit"<<endl; cout<<"Type 1 for display x Problem 1"<<endl; cout<<"Type 2 for 4 character Problem 2"<<endl; cout<<"Type 3 for check Problem 3"<<endl; cout<<"Type 4 for packages Problem 4"<<endl; cout<<"Type 5 for gross pay Problem 5"<<endl; cout<<"Type 6 for sequence Problem 6"<<endl; cout<<"Type 7 for Problem 7"<<endl<<endl; }

codeee/Quesiom 7.txt

#includeiostream using namespace std; struct declarations struct Prime { unsigned int prime; unsigned int power; }; struct Primes { Prime prime; unsigned int nPrimes; }; method to find all prime factors Primes factor(int n) { int k=2; int m[10000]={0};initially to store prime factors while(1n) { if(n%k==0) { m[k]++;finding prime factor n=nk; } else k++; coutk nendl; } after finding prime factors int i=0; k=0; while(i10000) { if(m[i]!=0)k++; i++; } Primes p = new Primes; p-nPrimes=k; p-prime = new Prime[k];creating prime array i=0; k=0; while(i10000) { if(m[i]!=0) { p-prime[k].prime = i; p-prime[k].power = m[i]; k++; } i++; } return p;returning primes structure } method to print primes void prnt(Primes p) { int n = p-nPrimes; int k=0; while(kn) { coutp-prime[k].prime^p-prime[k].power; k++; if(k==n-1)break; } coutp-prime[k].prime^p-prime[k].powerendl; } int main() { testing method Primes p= factor(120); coutFactors of 120; Prime n = new Prime[10]; prnt(p); return 0; } output

codeee/Question 1.txt

#include <bits/stdc++.h> using namespace std; struct Customer { string name; // Customers Name string address; // Customers address int account; // Five digit account number float balance; // Balance at the beginning of the month float cTotal[100]; // Total of all checks written by customer this month float dTotal[100]; //Total of all deposits credited to the account this month }; bool Check_Five_Digit(int n) { int c=0; while(n>0) { c++; n=n/10; } if(c==5) return true; else return false; } int main( ) { Customer* cus = new Customer; cout<<"Bank Account(Problem 1)"<<endl; string name,address; int checks, deposits,acc; float bal,sum=0,diff=0,total=0,x; cout << "Enter the name for the customer: "; getline(cin,name); cus->name=name; cout << "Enter the address : "; getline(cin, address); cus->address=address; cout << "Enter the five digit account number: "; cin >>acc; while(!Check_Five_Digit(acc)) { cout << "Invalid account number. Please enter a 5 digit account number: "; cin >> acc; } cus->account=acc; cout << "Enter the account balance: "; cin >> bal; sum = sum + bal; cout <<"How many checks did you write this month?: "; cin >> checks; for(int i = 0; i < checks; i++) { cout << "Enter the amount for the current check: "; cin >> x; cus->cTotal[i]=x; diff += x; } cout << "Total amount from checks: " << diff << endl; cout << "How many deposits would you like to enter for this month?: "; cin >> deposits; for(int i = 0; i < deposits; i++) { cout << "Enter the amount for the current deposit: "; cin >>x; cus->dTotal[i]=x; sum += x; } cout <<endl; cout << "Deposits: " << sum << endl; total = sum - diff; cout << "Account balance at the end of the month is: " << total << endl; if(total < 0) { cout<<"The account has been overdrawn. An additional $15 dollar fee has been accessed. The new balance is "<<(total - 15)<<endl; } cout <<cus->name << " at " << cus->address << " with the account " "number of " << cus->account << " has a balance of $" << total << endl; return 0; }

codeee/Question 2.txt

//system libraries #include <iostream> #include <string> #include <iomanip> using namespace std; #include "comdata.h" #include "empdata.h" const int THOSNDS=1000; const int HUNDRDS=100; const int TENS=10; void payCheck(EmpData, ComData); EmpData *addLine(EmpData *, EmpData, int); void pEmpCon(EmpData *, int); int main(int argc, char** argv) { ComData company; EmpData worker; int size=0; EmpData *worList=nullptr; //Input data on the company cout<<"Please enter the necessary information to fill out a check."<<endl; cout<<"Which company is this payroll for?"<<endl; getline (cin, company.comName); cout<<"Enter the street address of company:"<<endl; getline (cin, company.street); cout<<"Enter the city:"<<endl; getline(cin, company.city); cout<<"Enter the state:"<<endl; getline (cin, company.state); cout<<"Enter company zipcode:"<<endl; getline (cin, company.zip); cout<<"Enter the date this payrole is to be paid:"<<endl; getline (cin, company.date); cout<<"Enter the employee's name: "<<endl; getline(cin, worker.empName); cout<<"Enter the hours worked this week (Max of 80):"<<endl; cin>>worker.hrsWrkd; while (cin.fail() || worker.hrsWrkd>80 || worker.hrsWrkd<=0){ cout<<"Entry not valid! Enter a non-zero positive integer less than 80!"<<endl; cin.clear(); cin.ignore(256, '\n'); cin>>worker.hrsWrkd; } cout<<"Enter the rate of pay for this employee (Max of $133/hr) (0 or less to exit):"<<endl; cin>>worker.payRate; while (cin.fail() || worker.payRate>133 || worker.payRate<=0) { //validate data type and range cout<<"Entry not valid! Enter a non-zero positive integer of 133 or less!"<<endl; cin.clear(); cin.ignore(256, '\n'); cin>>worker.payRate; } size++; while (worker.hrsWrkd >0 && worker.payRate>0) { prnChck(worker, company); cout<<endl; worList=addLine(worList, worker, size); cout<<"Enter the employee's name: "<<endl; cin.ignore(256, '\n'); getline(cin, worker.empName); cout<<"Enter the hours worked this week (Max of 80) (0 or less to exit):"<<endl; cin>>worker.hrsWrkd; while (cin.fail() || worker.hrsWrkd>80){ //validate range and data type cout<<"Entry not valid! Enter a non-zero positive integer less than 80!"<<endl; cin.clear(); cin.ignore(256, '\n'); cin>>worker.hrsWrkd; } cout<<"Enter the rate of pay for this employee (Max of $133/hr):"<<endl; cin>>worker.payRate; while (cin.fail() || worker.payRate>133) { cout<<"Entry not valid! Enter a non-zero positive integer of 133 or less!"<<endl; cin.clear(); cin.ignore(256, '\n'); cin>>worker.payRate; } size++; } pEmpCon(worList, size); delete [] worList; return 0; } void pEmpCon(EmpData *a, int size){ cout<<setw(10)<<left<<"Emp. Num"<<setw(25)<<left<<"Name"<<setw(10)<<left<<"Hours"<<setw(10)<<left<<"Rate"<<endl; for (int i=0;i<size-1;i++){ cout<<setw(7)<<right<<i+1<<": "; cout<<setw(25)<<left<<a[i].empName; cout<<setw(10)<<left<<a[i].hrsWrkd; cout<<setw(10)<<left<<a[i].payRate<<endl; } } EmpData *addLine(EmpData *a, EmpData e, int size) { EmpData *tmp= new EmpData[size]; //create temp array if (size==1){ a=new EmpData[size]; a[size-1].empName=e.empName; a[size-1].hrsWrkd=e.hrsWrkd; a[size-1].payRate=e.payRate; } else { for (int i=0;i<size;i++){ tmp[i]=a[i]; } delete [] a; a=new EmpData[size]; for (int i=0;i<size;i++){ a[i]=tmp[i]; } a[size-1].empName=e.empName; a[size-1].hrsWrkd=e.hrsWrkd; a[size-1].payRate=e.payRate; } delete [] tmp; return a; } void prnChck(EmpData e, ComData c) { string date=c.date, holder=c.comName, payTo=e.empName, payFor="Payroll for hours worked"; unsigned short amount, tmpAmnt; char n1000,n100,n10,n1; string amtText=""; if (e.hrsWrkd<=40) amount=e.hrsWrkd*e.payRate; else if (e.hrsWrkd<=50) amount=(e.payRate*40+((e.hrsWrkd-40)*2*e.payRate)); else amount=(e.payRate*40+e.payRate*20+(((e.hrsWrkd-50)*3)*e.payRate)); tmpAmnt=amount; n1000=(tmpAmnt-tmpAmnt%THOSNDS)/THOSNDS; tmpAmnt=(tmpAmnt-n1000*THOSNDS); n100=(tmpAmnt-tmpAmnt%HUNDRDS)/HUNDRDS; tmpAmnt=(tmpAmnt-n100*HUNDRDS); n10=(tmpAmnt-tmpAmnt%TENS)/TENS; n1=(tmpAmnt-n10*TENS); switch(n1000){ case 19:amtText+="Nineteen Thousand ";break; case 18:amtText+="Eighteen Thousand ";break; case 17:amtText+="Seventeen Thousand ";break; case 16:amtText+="Sixteen Thousand ";break; case 15:amtText+="Fifteen Thousand ";break; case 14:amtText+="Fourteen Thousand ";break; case 13:amtText+="Thirteen Thousand ";break; case 12:amtText+="Twelve Thousand ";break; case 11:amtText+="Eleven Thousand ";break; case 10:amtText+="Ten Thousand ";break; case 9:amtText+="Nine Thousand ";break; case 8:amtText+="Eight Thousand ";break; case 7:amtText+="Seven Thousand ";break; case 6:amtText+="Six Thousand ";break; case 5:amtText+="Five Thousand ";break; case 4:amtText+="Four Thousand ";break; case 3:amtText+="Three Thousand ";break; case 2:amtText+="Two Thousand ";break; case 1:amtText+="One Thousand ";break; case 0:break; default:cout<<"ERROR SWITCH n1000"<<endl; } switch(n100){ case 9:amtText+="Nine Hundred ";break; case 8:amtText+="Eight Hundred ";break; case 7:amtText+="Seven Hundred ";break; case 6:amtText+="Six Hundred ";break; case 5:amtText+="Five Hundred ";break; case 4:amtText+="Four Hundred ";break; case 3:amtText+="Three Hundred ";break; case 2:amtText+="Two Hundred ";break; case 1:amtText+="One Hundred ";break; case 0:break; default:cout<<"ERROR SWITCH n100"<<endl; } switch(n10){ case 9:amtText+="Ninety ";break; case 8:amtText+="Eighty ";break; case 7:amtText+="Seventy ";break; case 6:amtText+="Sixty ";break; case 5:amtText+="Fifty ";break; case 4:amtText+="Forty ";break; case 3:amtText+="Thirty ";break; case 2:amtText+="Twenty ";break; case 1:break; case 0:break; default:cout<<"ERROR SWITCH n10"<<endl; } if (n10!=1){ switch(n1){ case 9:amtText+="Nine ";break; case 8:amtText+="Eight ";break; case 7:amtText+="Seven ";break; case 6:amtText+="Six ";break; case 5:amtText+="Five ";break; case 4:amtText+="Four ";break; case 3:amtText+="Three ";break; case 2:amtText+="Two ";break; case 1:amtText+="One ";break; case 0:break; default:cout<<"ERROR SWITCH n1"<<endl; } } if (n10==1) { switch(n1){ case 9:amtText+="Nineteen ";break; case 8:amtText+="Eighteen ";break; case 7:amtText+="Seventeen ";break; case 6:amtText+="Sixteen ";break; case 5:amtText+="Fifteen ";break; case 4:amtText+="Fourteen ";break; case 3:amtText+="Thirteen ";break; case 2:amtText+="Twelve ";break; case 1:amtText+="Eleven ";break; case 0:break; default:cout<<"ERROR SWITCH n1"<<endl; } } cout<<"Printing Check!"<<endl<<endl; cout<<setw(50)<<left<<holder<<setw(10)<<right<<"Date: "<<c.date<<endl; cout<<c.street<<endl; cout<<c.city+", "<<c.state+" "<<c.zip<<endl; cout<<"Pay to the order of: "<<setw(25)<<left<<payTo<<setw(21)<<right <<"Amount: $"<<setw(5)<<right<<amount<<".00"<<endl<<endl; cout<<"The Amount Of: "<<amtText<<"dollars and 00/100 "<<endl<<endl; cout<<"ICICI Bank"<<setw(61)<<right<<holder<<endl; cout<<"Memo: "<<setw(59)<<left<<payFor<<setw(10)<<right<<"Signature"<<endl; }

codeee/Question 3.txt

Not answerd yet

codeee/Question 4.txt

main.cpp #include<iostream> using namespace std; void encrypt(int a) { int first,second,third,fourth; //for storing respective digit of a fourth=a%10; //storing fourth digit of a a/=10; //dividing a by 10 third=a%10; //storing third digit of a a/=10; //dividing a by 10 second=a%10; //storing second digit of a a/=10; //dividing a by 10 first=a; //storing first digit of a if(first==8||first==9||second==8||second==9||third==8||third==9||fourth==8||fourth==9) { //if any digit is 8 or 9 print error message and return cout<<"8 or 9 cannot be in the number\n\n"; return; } //encrypting each digit first=(first+5)%8; second=(second+5)%8; third=(third+5)%8; fourth=(fourth+5)%8; //the number should be number=1000*first+100*second+10*third+fourth //but swapping first with third and second with fourth int number=1000*third+100*fourth+10*first+second; cout<<"Encrypted number is "<<number<<endl; //displaying the number } void decrypt(int a) { int first,second,third,fourth; //for storing respective digit of a fourth=a%10; //storing fourth digit of a a/=10; //dividing a by 10 third=a%10; //storing third digit of a a/=10; //dividing a by 10 second=a%10; //storing second digit of a a/=10; //dividing a by 10 first=a; //storing first digit of a if(first==8||first==9||second==8||second==9||third==8||third==9||fourth==8||fourth==9) { //if any digit is 8 or 9 print error message and return cout<<"8 or 9 cannot be in the number\n\n"; return; } //For decrypting we have to decrement 5 but the digit can become //negative so also adding 8 so that digits remains positive first=(first-5+8)%8; second=(second+3)%8; third=(third+3)%8; fourth=(fourth+3)%8; //the number should be number=1000*first+100*second+10*third+fourth //but swapping first with third and second with fourth int number=1000*third+100*fourth+10*first+second; cout<<"Decrypted number is "<<number<<endl; //displaying decrypted number } int main() { int number; cout<<"Enter the number to be encrypted: "; cin>>number; //user entering number to be encrypted encrypt(number); //encrypting number cout<<"Enter the number to be decrypted: "; cin>>number; //user entering number to be decrypted decrypt(number); //decrypting number return 0; }

codeee/Question 5.txt

//system libraries #include <iostream> using namespace std; //for byte type short factorial_byte() { short int n=1; short int f=1; short int pf; while(1) //repeat true enter loop { pf=f;//get previous factorial to pf, pf follows f previous value before range of f f=f*n; n++;//decrement n if(f<127) continue;//when out of range 127, stop the loop else break; } return pf; //return the largest factorial n, ie., pf } //for int type int factorial_int() { int n=1; int f=1; int pf; while(1) //repeat true enter loop { pf=f;//get previous factorial to pf, pf follows f previous value before range of f f=f*n; n++;//decrement n if(f<32767) continue;//when out of range 32767, stop the loop else break; } return pf; //return the largest factorial n, ie., pf } //for long int type long int factorial_long() { long n=1; long f=1; long pf; while(1) //repeat true enter loop { pf=f;//get previous factorial to pf, pf follows f previous value before range of f f=f*n; n++;//decrement n if(f<2147483647) continue;//when out of range 2147483647, stop the loop else break; } return pf; //return the largest factorial n, ie., pf } //for float type float factorial_float() { float n=1; float f=1; float pf; while(1) //repeat true enter loop { pf=f;//get previous factorial to pf, pf follows f previous value before range of f f=f*n; n++;//decrement n if(f<9999999) continue;//when out of range maximum 7 digit value else break; } return pf; //return the largest factorial n, ie., pf } //for double type double factorial_double() { double n=1; double f=1; double pf; while(1) //repeat true enter loop { pf=f;//get previous factorial to pf, pf follows f previous value before range of f f=f*n; n++;//decrement n if(f<999999999999999) continue;//when out of range maximum 15 digit value else break; } return pf; //return the largest factorial n, ie., pf } //main program here int main() { cout<<"\nLargest factorial from byte type: "<<factorial_byte(); cout<<"\nLargest factorial from int type: "<<factorial_int(); cout<<"\nLargest factorial from long int type: "<<factorial_long(); cout<<"\nLargest factorial from float type: "<<factorial_float(); cout<<"\nLargest factorial from double type: "<<factorial_double(); return 0; }

codeee/Question 6/Screenshot (1143).png

codeee/Question 6/Screenshot (1144).png

codeee/Question 6/Screenshot (1145).png