1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Korolek [52]
3 years ago
7

A store owner keeps a record of daily transactions in a text file. Each line contains three items: The invoice number, the cash

amount, and the letter P if the amount was paid or R if the amount was received. Items on each line are separated by spaces. Wri te a program that prompts the store owner for the amount of cash at the beginning of the day and for the amount of cash at the end of the day, as well as the name of the ledger text file. Your program should calculate if the actual amount of cash at the en d of the day equals the expected value. If an error is found while reading the text file, the user should be allowed to choose another file
Computers and Technology
1 answer:
Alex17521 [72]3 years ago
5 0

Answer:

Answer explained below

Explanation:

Java Program:

package ledger;

import java.util.*;

import java.io.*;

public class Ledger {

   //Main method

   public static void main(String[] args) throws FileNotFoundException {

     

       String fileName;

     

       try

       {

           //Reading file name

           fileName = getFileName();

                 

           //Processing file

           processFile(fileName);

       }

       catch(Exception ex)

       {

           //Reading file name

           fileName = getFileName();

                 

           //Processing file

           processFile(fileName);

       }

     

   }

 

   //Reading file name

   public static String getFileName()

   {

       String fileName;

     

       Scanner sc = new Scanner(System.in);

     

       //Prompting user for file name

       System.out.print("\n\n Enter ledger text file name: ");

     

       //Reading and storing file name

       fileName = sc.nextLine();

     

       return fileName;

   }

 

   //Method that process the file

   public static void processFile(String fileName) throws FileNotFoundException

   {

       //Scanner class object for reading file

       Scanner reader = new Scanner(new File(fileName));

     

       double startingBalance, endingBalance, amount, balance;

       String transactionType, invoiceNum;

     

       //Scanner class object

       Scanner sc = new Scanner(System.in);

     

       //Reading starting balance

       System.out.print("\n Enter Starting Balance: ");

       startingBalance = sc.nextDouble();

     

       //Reading ending balance

       System.out.print("\n Enter Ending Balance: ");

       endingBalance = sc.nextDouble();

     

       //Initiall balance is starting balance

       balance = startingBalance;

     

       //Reading data

       while(reader.hasNext())

       {

           //Reading invoice number

           invoiceNum = reader.next();

         

           //Reading amount

           amount = reader.nextDouble();

         

           //Reading transaction type

           transactionType = reader.next();

         

           //For Paid transactions

           if(transactionType.equalsIgnoreCase("P"))

           {

               balance = balance - amount;

           }

           //For Received transactions

           else

           {

               balance = balance + amount;

           }

       }

     

       System.out.println("\n\n Ledger Balance: " + balance);

     

       //Closing file

       reader.close();

     

       //Comparing ending balance

       if(balance == endingBalance)

       {

           System.out.println("\n Actual amount matches with the expected value.... \n");

       }

       else

       {

           System.out.println("\n Sorry!!! Actual amount doesn't match with the expected value.... \n");

       }

   }

}

You might be interested in
Corey wrote a code that will display his name every time he presses the down arrow key but there is a bug in it. Display letter
brilliants [131]

Answer:

Explanation:

display letter c, type letter r, type letter o, type letter 3, type letter y- i think thats it but i dee cay this is confusing

7 0
3 years ago
Explain the importance of mobile computing in communication​
ludmilkaskok [199]
<h3><em><u>Importance of Mobile computing in communication</u></em></h3>

*It’s portable and easy-to-use.

*It helps for different communication and information exchange.

*It saves user’s time and effort.

*It provides quick services like online business, e-mail, e-fax, etc.

*It increases the social interaction by sharing location services and GPS system.

7 0
3 years ago
Read 2 more answers
Network access control authenticates users logging into the network and determines what data they can access and actions they ca
erik [133]

Answer:

The answer is letter A

Explanation:

The statement is TRUE

3 0
4 years ago
We assume that ABC Corporation has two business offices. These offices are in the cities of Orlando and Miami. These cities are
murzikaleks [220]

Answer:

The following are the answer to the given points:

Explanation:

In point (a):

Calculating the long-distance call cost:

= 4 \times 5 \times 0.40 \\= 20 \times 0.40\\= 8

Calculating the local call cost:

= 10 \times 3  \times 0.05\\ = 30 \times 0.05\\= 1.5

Calculating the overall cost of PSTN:

= 25 + (4 \times 5 \times 0.40) + (10 \times 3 \times 0.05) + 2000 + 275 \\= 25 + 8 + 1.5 + 2000 + 275 \\=   2309.5

In point (b):

Calculating the call rate per second and the average arrival rate:

\to (\lambda) = 0.2

The call average length:

\to (T_s) = - 8  \\\\ = (8  \times 60) \ seconds \\\\ = 480 \ seconds  

The complete agent number:

\to  (m) = 9

The strength of traffic:

\to u = \lambda \times  T_s  \\\\  =   (0.2  \times 480) \\\\ = 96    

The occupancy of the agent:

\to  p = \frac{u}{m}  \\\\

      = \frac{96}{9}  \\ \\= 10.66  

Calculation of obtained:

= \frac{(\frac{um}{m!})}{(\frac{um}{m!})} + (1-p) \sum {m-1} _{k=0}  \ \frac{uk}{k!}

We get = 0.329 to substitute values.  

In point (c):

The rate of blocking = 5 \%

average call time (T_s) = 480 \ seconds

                                    = 0.05 \times  480 \ seconds \\  = 24 \ second

In point (d):

Calculating the number of link, which is required:  

= \frac{275}{5} \\\\ =55

In point (e):

Calculating the Line Number:

= \frac{275}{5} \\\\ =55

PSTN line number:

=  (\frac{2000}{55}) \\\\ = 36.3636\\\\= 37

In point (f):

The gross design expense = $ 2309. 5

5 0
4 years ago
_____ (without parity) means spreading the data among multiple (at least two) drives. Group of answer choices Parity
Llana [10]

Answer:

"Disk Striping" would be the right choice.

Explanation:

  • Disk stripping has become a methodology where certain numerous small external drives consist of a single massive disk. This same classification turns huge information into single blocks but instead disperses them over numerous different storage media.
  • Disk stripping retail outlets instead of every data unit through a single place and doesn't provide disk failure safeguards.
3 0
3 years ago
Other questions:
  • If a windows computer belongs to a domain, all security is managed by the network administrator for the entire network. true
    15·1 answer
  • An example of live footage is when?
    10·2 answers
  • Keion works as a freelancer creating websites and designing logos for clients. He recently had a hard drive failure and lost wor
    12·1 answer
  • Assume that a text box named PhoneNumberTextBox appears on a form and contains the phone number 414-555-5555. What value will di
    5·1 answer
  • In the legend of sleeping Hallow what does Ichabod Crane fear the most
    13·2 answers
  • How can you prevent your VMs receiving DHCP server messages from unauthorized virtual machine pretending to be DHCP servers?
    13·1 answer
  • Under which tab would you look to find the Show in Groups and advanced sort options for messages in Outlook?
    11·2 answers
  • Keli is unable to find a shape that meets her needs. Which feature in Power Point should she use to create shapes that are compl
    6·1 answer
  • The Fast as Light Shipping company charges the following rates. Weight of the item being sent Rate per 100 Miles shipped 2kg or
    13·1 answer
  • Question is attached as image, please help :&gt;
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!