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
A _____ describes two or more computers connected to each other.
Soloha48 [4]
I’m pretty sure it’s server
4 0
3 years ago
Read 2 more answers
Which steps of the management science process can either be a recommended decision or information that helps a manager a decisio
Step2247 [10]
Probably c or a with the question your asking
8 0
2 years ago
owever, sitting in a corner of the store, a hacker had just set up an open "rogue" wireless hotspot posing as the coffee shop’s
Ivenika [448]

However, sitting in a corner of the store, a hacker had just placed up an open “rogue” wireless hotspot posing as the coffee shop’s wireless network. When Sarah logged onto her bank’s website, the hacker hijacked her session and gained access to her bank accounts. Another term for rogue wireless hotspots exists as “evil twin” hotspots.

<h3>What is meant by wireless network?</h3>

A computer network is referred to as a wireless network if radio frequency (RF) links are used to connect network nodes. A common solution for households, companies, and telecommunications networks is wireless networking. Wi-Fi is a wireless networking technology that enables printers and video cameras to connect to the Internet as well as computers (laptops and desktops), mobile devices (smart phones, wearables, etc.), and other devices.

Increased Mobility: Wireless networks give mobile users access to real-time data, enabling them to move freely across the premises of your firm without losing network connectivity. This improves collaboration and production across the entire organisation, which is not achievable with traditional networks.

Hence, However, sitting in a corner of the store, a hacker had just placed up an open “rogue” wireless hotspot posing as the coffee shop’s wireless network. When Sarah logged onto her bank’s website, the hacker hijacked her session and gained access to her bank accounts. Another term for rogue wireless hotspots exists as “evil twin” hotspots.

To learn more about wireless network refer to:

brainly.com/question/26956118

#SPJ4

6 0
1 year ago
You're the sole IT employee at your company, and you don't know how many users or computers are in your organization. Uh oh! Wha
Neporo4naja [7]

Answer

Directory Services

<u></u>

<u>Definition</u>

It is a type of software that is used to unify and customize the resources available at the network.

<u>Explanation</u>

This software is used to gather the information and addresses of all computers connected on the network.

It is a type of information store, where all the information related to resources (computer) and services of network has been stored. It also gives administrator rights to the single point to manage whole network resources.

This is the reason, Option "D" is the best choice for me as sole IT employ in a company. I will prefer directory services software to gather the information of all computers of organization and manage users in company.  

4 0
3 years ago
'|'/2`/ '|'[] |)[-([]|)[- '|'#!$
natita [175]

Answer: mr Man

Explanation:

7 0
3 years ago
Other questions:
  • What does it mean to say that two variables are negatively correlated?
    6·1 answer
  • Helena purchased a security software package to protect her new laptop against threats such as spyware and computer viruses. she
    14·1 answer
  • Type the correct answer in the box.
    15·1 answer
  • What is the purpose of application software policies?
    12·1 answer
  • In 2009 to 2010, 1 in 10 social network users:
    10·1 answer
  • Intranets:
    8·1 answer
  • Describe five examples of civil engineering projects.
    6·1 answer
  • Ivan wants to have code in a game that will make it possible to change the speed of a swimmer in the game. Which of these does I
    8·1 answer
  • How do you get off of the comments after you look at them wit out going all the way off the app?
    15·1 answer
  • Which are examples of basic text structures? Check all that apply.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!