convert the program to java CODE: #include #include #include #include #include #include #include // header for random number generator (account number) using namespace std; void opt1(); void header(); void menu(); void members(); void newAccount(); void opt(); void enterContinue(); void enterContinue1(); void pinCheck(int& x); /*void close();*/ int length(int x); int main() { int op1, decide, option, accountNumber, pin, pinLength = 0; bool openAcc = 0; double depositAmount, withdrawAmount, totalAmount = 0; char decide1 = ' ', closeAccount; srand(time(NULL)); // random number generator string name; header(); members(); do { header(); menu(); cout << "\n\t\t\tSelect an option (1-7): "; cin >> option; system("cls"); switch (option) { case 3: /////////////////////////////////////////////////////////// Withdraw Amount header(); cout << "\n\t\t\t WITHDRAW AMOUNT " << "\n"; cout << "\n\t\t\t============================ " << endl; if (openAcc == true) { // If there is an existing account, the program will let the user withdraw. pinCheck(pin); // Will ask the user to input their pin for security purposes. cout << "\n\t\t\t----------------------------" << endl; withdraw: cout << "\n\t\t\tHow much would you like to withdraw?" << endl; cout << "\n\t\t\t$ "; cin >> withdrawAmount; if (withdrawAmount > totalAmount) { // The system will not allow the user to withdraw amounts larger than their current balance. cout << "\n\t\t\tInsufficient funds."; cout << "\n\t\t\tPlease try again." << endl; goto withdraw; } else if (withdrawAmount < 0) { // The system will not allow the user to input a negative amount. cout << "\n\t\t\tYou cannot withdraw a negative amount."; cout << "\n\t\t\tPlease try again." << endl; goto withdraw; } else { //The total amount will now be updated based on the withdrawal done. totalAmount = totalAmount - withdrawAmount; cout << "\n\t\t\t----------------------------" << endl; cout << "\n\t\t\tYour new balance is $" << totalAmount << "." << endl; } } case 4: /////////////////////////////////////////////////////////// Balance Inquiry header(); cout << "\n\t\t\t BALANCE INQUIRY " << "\n"; cout << "\n\t\t\t============================" << endl; if (openAcc == 1) { // The system will only allow the user to continue with the transaction if there is an account open. pinCheck(pin); // Will ask the user to input their pin for security purposes. cout << "\n\t\t\t----------------------------" << endl; cout << "\n\t\t\tYour current balance is $" << totalAmount << "." << endl; } else { // Will not let the user to check their balance if there is no existing account. cout << "\n\t\t\tPlease create an account first." << endl; } cout << "\n\t\t\t----------------------------" << endl; enterContinue(); break; else { // Will not let the user withdraw if there is no existing account. cout << "\n\t\t\tPlease create an account first." << endl; } cout << "\n\t\t\t----------------------------" << endl; enterContinue(); break;
convert the program to java
CODE:
#include <stdio.h>
#include <direct.h>
#include <stdlib.h>
#include <iostream>
#include <conio.h>
#include <string>
#include <ctime> // header for random number generator (account number)
using namespace std;
void opt1();
void header();
void menu();
void members();
void newAccount();
void opt();
void enterContinue();
void enterContinue1();
void pinCheck(int& x);
/*void close();*/
int length(int x);
int main()
{
int op1, decide, option, accountNumber, pin, pinLength = 0;
bool openAcc = 0;
double depositAmount, withdrawAmount, totalAmount = 0;
char decide1 = ' ', closeAccount;
srand(time(NULL)); // random number generator
string name;
header();
members();
do
{
header();
menu();
cout << "\n\t\t\tSelect an option (1-7): ";
cin >> option;
system("cls");
switch (option) {
case 3: /////////////////////////////////////////////////////////// Withdraw Amount
header();
cout << "\n\t\t\t WITHDRAW AMOUNT " << "\n";
cout << "\n\t\t\t============================ " << endl;
if (openAcc == true) { // If there is an existing account, the program will let the user withdraw.
pinCheck(pin); // Will ask the user to input their pin for security purposes.
cout << "\n\t\t\t----------------------------" << endl;
withdraw:
cout << "\n\t\t\tHow much would you like to withdraw?" << endl;
cout << "\n\t\t\t$ ";
cin >> withdrawAmount;
if (withdrawAmount > totalAmount) { // The system will not allow the user to withdraw amounts larger than their current balance.
cout << "\n\t\t\tInsufficient funds.";
cout << "\n\t\t\tPlease try again." << endl;
goto withdraw;
}
else if (withdrawAmount < 0) { // The system will not allow the user to input a negative amount.
cout << "\n\t\t\tYou cannot withdraw a negative amount.";
cout << "\n\t\t\tPlease try again." << endl;
goto withdraw;
}
else { //The total amount will now be updated based on the withdrawal done.
totalAmount = totalAmount - withdrawAmount;
cout << "\n\t\t\t----------------------------" << endl;
cout << "\n\t\t\tYour new balance is $" << totalAmount << "." << endl;
}
}
case 4: /////////////////////////////////////////////////////////// Balance Inquiry
header();
cout << "\n\t\t\t BALANCE INQUIRY " << "\n";
cout << "\n\t\t\t============================" << endl;
if (openAcc == 1) { // The system will only allow the user to continue with the transaction if there is an account open.
pinCheck(pin); // Will ask the user to input their pin for security purposes.
cout << "\n\t\t\t----------------------------" << endl;
cout << "\n\t\t\tYour current balance is $" << totalAmount << "." << endl;
}
else { // Will not let the user to check their balance if there is no existing account.
cout << "\n\t\t\tPlease create an account first." << endl;
}
cout << "\n\t\t\t----------------------------" << endl;
enterContinue();
break;
else { // Will not let the user withdraw if there is no existing account.
cout << "\n\t\t\tPlease create an account first." << endl;
}
cout << "\n\t\t\t----------------------------" << endl;
enterContinue();
break;
Step by step
Solved in 2 steps