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]
2 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]2 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
When someone refers to "space" on a computer or device, they are usually referring to _____, which allows the user to save a fil
Mama L [17]

Answer:

Memory.

Explanation:

When someone refers to "space" on a computer or device, they are usually referring to memory, which allows the user to save a file for future use, even after the computer has been turned off.

In Computer science, a memory is a term used to describe the available space or an electronic device that is typically used for the storage of data or any computer related information such as images, videos, texts, music, codes and folders. There are basically two (2) main types of memory;

1. Read only memory (ROM).

2. Random access memory (RAM).

3 0
3 years ago
Ok so I usually don’t do this but I just need an answer , on Instagram a notification popped up while I was watching someone’s s
statuscvo [17]

Answer:

I think it was about cheaper ads on Instagram and how they are lowering their prices.

Explanation:

6 0
3 years ago
Read 2 more answers
AirPods se están despintando al ponerlos en quitaesmalte ayudaaaa?
slega [8]

Answer:

In reality, a diluted type of acetone that dissolves plastics and coating is Nail polish removers.

Explanation:

The chemical composition of the material has permanently changed, nothing else than if you had shot it. No repair but replacement is available.

Acetone does not get along with plastics.

This classic timelapse video shows just how cheap plastic acetone is.

When it's out, I have my new AirPods Pro. I got a odd smell when I opened the box when I received it. The little one is solid and chemical. It's new, I guess, and after days it will be gone.

But after ten days of use it doesn't. And the smell remains strong. It won't go quickly, I believe.

Instead I noticed that the smell is often shaping the silicone tips.

About 8 hours a day I use this AirPods Pro. Is it possible for a long time to use this smelling tip?

Actually, I must say they are soft and work well for noise cancelation, I love this silicone tip. If the strange smell doesn't hurt. To me, that's good.

6 0
3 years ago
You have decided to install the DNS server role on Nano Server. What specific type of zone configuration is not supported when u
nadya68 [22]

Answer:Active Directory-integrated

Explanation: Active Directory-integrated is the service that is introduced by the Microsoft .This service provides the directory form for functioning in Windows. It serves the purpose of active directory(AD) transferring to the Dynamic web database. Whenever the user gets connected to any website, it provides validation to qualifications . So, it does not get support the specification when there is working of DNS.

4 0
3 years ago
Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
Zarrin [17]

Answer:

Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred and indistinct, as companies that compete one day may be partners the next. So "Lines" cannot be compared to/with internet companies.

Explanation:

The Internet Industry  is shaped by its unique framework outlining and its own rules between the companies within it, which offer a vast number of products and services and not always competing with each other compared with the traditional established industries competition lines that were developed from two parties or more aiming the same unshareable goal. These industries are stablishing the lines of competitions predicament which by all means can not be measured and applied using the same criteria for both of them.

The online industry is claiming for flexible, pliant lines of competition to be inforced to its specific logic and mechanisms.

The companies are now in a brand new competing ground with the digital area, so traditional established bart lines of competition although clear and defined are becoming obsolete facing the current surprising thus blurred and indistict internet industry lines.

6 0
2 years ago
Other questions:
  • true or false: for most queries, the user location changes our understanding of the query and user intent.
    13·1 answer
  • What is the lowest and highest address of a 2^20 byte memory, if it is byte readable.
    11·1 answer
  • Constantine forms the following hypothesis. Let n be any non-negative number that meets the following condition: when n is divid
    10·1 answer
  • When evaluating portable CD players, you consider price, the sound quality, and ease of using the controls. These are your _____
    8·2 answers
  • the easiest and cheapest time to alter the information system is in the ________ phase of the sdlc. a. requirements analysis b.
    8·1 answer
  • I have all the points to level up to virtuoso, but it hasn't yet does anyone know when it will?
    9·1 answer
  • When a formula contains the address of a cell, it is called a(n) ________.
    15·1 answer
  • Which of the following are documents that can help you to review and assess your organization’s status and state of security? Fi
    6·1 answer
  • What is the role of the federal government in regulating the media and the internet?
    6·2 answers
  • ________ is a group meeting-based process for requirements collection. a. Reverse engineering b. Joint application design c. Hum
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!