Question

In: Computer Science

Creation of Program Application (Development Task 1) This program should create two output files. You may...

Creation of Program Application (Development Task 1)

This program should create two output files.

You may use .txt files.

Create the following files:

Deposists.txt

Withdrawls.txt

1. The program application should have the following inputs: Amount for Deposits (Only Accept Positive Amounts) Amount for Withdrawals (Only Accept Positive Amounts). The subsequent program will subtract the positive amount.

2. The program application should have the following outputs:

Deposists.txt

Withdrawals.txt

Total of Deposits and Withdrawals back to the console

Solutions

Expert Solution

//create DevelopmentTask1.java class in any editor


import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class DevelopmentTask1 {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//create two file Deposits.txt and Withdrawls.txt
String input = "";
while (!input.equals("n")) {
try {
System.out.println("1. Deposite\n2. Withdrawl\n3.Display\n4.Quit");
System.out.print("Enter your option:");
int option = sc.nextInt();
switch (option) {
case 1:
System.out.println("Enter Amount to be deposite(Only greater than zero)");
double deposite = 0;
while (deposite <= 0) {
System.out.print("Enter Positive Number:");
deposite = sc.nextDouble();
}
FileWriter writer = new FileWriter(new File("Deposite.txt"), true);
writer.append("" + deposite + "\n");
writer.close();
break;
case 2:
System.out.println("Enter Amount to be withdrawl(Only greater than zero)");
double withdrawl = 0;
while (withdrawl <= 0) {
System.out.print("Enter Positive Number:");
withdrawl = sc.nextDouble();
}
writer = new FileWriter(new File("Withdrawls.txt"), true);
writer.append("" + withdrawl + "\n");
writer.close();
break;
case 3:
//Total of deposite and withdrawl back to console

Scanner myReader = new Scanner(new File("Deposite.txt"));//read file object
double total_deposite = 0,
total_withdrawl = 0;
while (myReader.hasNextLine()) {
try {
String data = myReader.nextLine();//read each file line
total_deposite += Double.parseDouble(data);
} catch (Exception e) {
e.printStackTrace();
}
}
myReader = new Scanner(new File("Withdrawls.txt"));//read file object
while (myReader.hasNextLine()) {
try {
String data = myReader.nextLine();//read each file line
total_withdrawl += Double.parseDouble(data);
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("Total Deposite Value is: " + total_deposite);
System.out.println("Total Withdrawl Value is: " + total_withdrawl);
break;

case 4:
input = "n";
break;
}

} catch (Exception ee) {
ee.printStackTrace();
}
}
}
}

----------------------------------------------------------OUTPUT-----------------------------------------------------------------------------------

run:
1. Deposite
2. Withdrawl
3.Display
4.Quit
Enter your option:1
Enter Amount to be deposite(Only greater than zero)
Enter Positive Number:200
1. Deposite
2. Withdrawl
3.Display
4.Quit
Enter your option:2
Enter Amount to be withdrawl(Only greater than zero)
Enter Positive Number:100
1. Deposite
2. Withdrawl
3.Display
4.Quit
Enter your option:3
Total Deposite Value is: 600.0
Total Withdrawl Value is: 100.0
1. Deposite
2. Withdrawl
3.Display
4.Quit
Enter your option:4
BUILD SUCCESSFUL (total time: 17 seconds)


Related Solutions

B. Creation of Program Application (Development Task 1) This program should ask the following questions to...
B. Creation of Program Application (Development Task 1) This program should ask the following questions to determine the number of hotdogs and buns (with minimum number of leftovers) needed for the Annual Hotdog Eating contest: Assumptions are as follows: • Hotdogs come in packages of 10. • Hotdog buns come in packages of 8. 1. The program application should have the following inputs: • How many people will be competing in the contest? • How many hotdogs will each person...
I am using Java and what do you mean samples? Creation of Program Application (Development Task...
I am using Java and what do you mean samples? Creation of Program Application (Development Task 2) This program should use a class file you create called: SavingsAccount. This class file should store the following information: Annual Interest Rate (this can be hardcoded) Starting Balance (use a constructor to accept this information) Create method to add all Deposits from Deposits.txt file. Create method to subtract all Withdrawals from Withdrawals.txt file. Create method to calculate the interest rate which is the...
In this task, you will create a Python script in which you will practice reading files...
In this task, you will create a Python script in which you will practice reading files in Python and writing them to a new output file. Construct a text file called Py4_Task3_input.txt that has the following lines: 4 Sandwiches 04 July 2020 Pasta 31 October 2014 Hot Dogs 15 November 2005 Tacos 25 December 1986 The first line of the file represents the number of lines in the data file. Write a loop that reads in each additional line (one...
Create a simple C++ application that will exhibit concurrencyconcepts. Your application should create two threads...
Create a simple C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0. For your created code, provide a detailed analysis of appropriate concepts that could impact your application. Specifically, address:Performance issues with concurrencyVulnerabilities exhibited with use of stringsSecurity of the data types exhibited.
You will write a Java Application program to perform the task of generating a calendar for...
You will write a Java Application program to perform the task of generating a calendar for the year 2020. You are required to modularize your code, i.e. break your code into different modules for different tasks in the calendar and use method calls to execute the different modules in your program. Your required to use arrays, ArrayList, methods, classes, inheritance, control structures like "if else", switch, compound expressions, etc. where applicable in your program. Your program should be interactive and...
Create a Java application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
JAVACreate a Java application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.
Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
C++Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.
Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters.
C++ application:Create a C++ application that will exhibit concurrency concepts. Your application should create two threads that will act as counters. One thread should count up to 20. Once thread one reaches 20, then a second thread should be used to count down to 0.For your created code, provide a written analysis of appropriate concepts that could impact your application.Please Specifically, Address: Performance Issues with Concurrency Vulnerabilities Exhibited with use of Strings and Security of the Data Types used.
1. Write an application that prints the following diamond shape. You may use output statements that...
1. Write an application that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space or a single newline character. Maximize your use of repetition (with nested for statements), and minimize the number of output statements 2. Modify the application you wrote in Exercise 5.20 (Question 1 Above) to read an odd number in the range 1 to 19 to specify the number of rows in the diamond. Your program should...
Edit question Write a program that merges two files as follows. The two files are in...
Edit question Write a program that merges two files as follows. The two files are in the docsharing which you can download it. One file will contain usernames(usernames.txt):foster001smith023nyuyen002...The other file will contain passwords(passwords.txt):x34rdf3ep43e4rddw32eds22...The program should create a third file matching username and passwords(usernamesPasswords.txt):foster001x34rdf3esmith023p43e4rddnyuyen002w32eds22......Give the user of your programs the option of displaying you output file. CAN ANYONE SOLVE THIS IN C
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT