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
lord [1]
3 years ago
8

Geraldine's Landscaping Service and Gerard's Lawn Maintenance are merging their businesses and want to merge their customer file

s. Each file contains a customer number, last name, address, and property area in square feet, and each file is in customer number order. Design the logic for a program that merges the two files into one file containing all customers. Assume there are no identical customer numbers.
Computers and Technology
1 answer:
irina [24]3 years ago
3 0

Answer:

Check the explanation

Explanation:

Steps to follow:-

Read file1 or file2

Get number from line of file1

Check numberlist contains this number

if number is not in numberlist then add number to numberlist

Write line of file1 to outputFile

Read file2

Get number from line of file2

Check numberlist contains this number  

if number is not in numberlist then add number ot numberlist

Write line of file2 to outputFile

Repeat the above process untill file line is not null

Complete Java code:-

import java.io.*;

import java.util.*;

public class Solution {

   public static void main(String[] args)

   {

       mergerFiles();

   }

 public static void mergerFiles()

 {

     try {

        FileReader fileReader1 = new FileReader("res/file1");

         BufferedReader bufferedReader1 = new BufferedReader(fileReader1);

         FileReader fileReader2 = new FileReader("res/file2");

         BufferedReader bufferedReader2 = new BufferedReader(fileReader2);

         FileWriter fileWriter = new FileWriter("res/outputfile");

         BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

         String file1Line=null;

         String file2Line=null;

         Set<String> set=new HashSet();

         while(((file1Line = bufferedReader1.readLine()) != null) || (file2Line = bufferedReader2.readLine())!= null) {

             String number1=file1Line.split(",")[0].split(":")[1];

             if(set.add(number1))

             {

                 bufferedWriter.write(file1Line+"\n");

             }

             if((file2Line = bufferedReader2.readLine())!= null) {

                 String number2 = file2Line.split(",")[0].split(":")[1];

                 if (set.add(number2)) {

                     bufferedWriter.write(file2Line+"\n");

                 }

             }

         }

         bufferedWriter.close();

     } catch (FileNotFoundException e) {

         e.printStackTrace();

     } catch (IOException e) {

         e.printStackTrace();

     }

 }

}

File1 content:-

number:1234567890, lastname: Kumar, address: delhi, property:2000 sqft

number:2234567890, lastname: Chaudhari, address: Pune, property:4000 sqft

number:3234567890, lastname: Singh, address: Mumbai, property:2500 sqft

number:4234567890, lastname: Varma, address: Kolkata, property:5000 sqft

number:5234567890, lastname: Sinha, address: Patna, property:6000 sqft

File2 content:-

number:4234567890, lastname: Ram, address: bangalore, property:25000 sqft

number:6234567890, lastname: Rajput, address: Ranchi, property:40400 sqft

number:3234567890, lastname: Sinha, address: Gurgaon, property:25300 sqft

number:4234567890, lastname: Kaur, address: Chennai, property:50200 sqft

number:8234567890, lastname: Mehta, address: Pondicherry, property:26000 sqft

Output file content:-

number:1234567890, lastname: Kumar, address: delhi, property:2000 sqft

number:4234567890, lastname: Ram, address: bangalore, property:25000 sqft

number:2234567890, lastname: Chaudhari, address: Pune, property:4000 sqft

number:6234567890, lastname: Rajput, address: Ranchi, property:40400 sqft

number:3234567890, lastname: Singh, address: Mumbai, property:2500 sqft

number:5234567890, lastname: Sinha, address: Patna, property:6000 sqft

number:8234567890, lastname: Mehta, address: Pondicherry, property:26000 sqft

You might be interested in
In Word, tables can be styled much like text can.<br> True<br> False
Delvig [45]

Answer:

True

Explanation:

There are many formatting options from color, size, and many more.

Hope this helps!

3 0
3 years ago
What is one concern associated with web-based applications?
damaskus [11]

Answer:

Security

Explanation:

If you dont have security, all the other will be broken, its like laws of physics

5 0
3 years ago
_____ provide the standards, syntax, statements, and instructions for writing computer software
miv72 [106K]
<span>Programming languages provide the standards, syntax, statements, and instructions for writing computer software.
</span>It is a vocabulary and set of grammatical rules. These rules are used for instructing a computer<span> or computing device to perform specific tasks and produce a certain output.</span>
4 0
3 years ago
It takes an older computer twice as long to send out a company's email as it does a newer computer. Working together, it takes t
bulgar [2K]

Answer:

13,33  MIN.

Explanation:

1. Time with Older Computer (OC) = 2 time with New Computer (NC)

2. OC+ NC = 10 MIN.

replacing 1. in 2.    OC + OC/2 = 10 min.  

1.5 OC =10min

OC=6.66 MIN

NC = 3,33 MIN.

If we replace NC with OC , 3,33 min will take 2 times (6,66 min)

Total Time = 6,66 + 6,66= 13,33 min

4 0
3 years ago
Who created the first photograph
Tems11 [23]
Nicephore Niepce created the first photograph.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
    5·1 answer
  • Design and implement your own simple class to represent any household item of your choice (toaster, fan, hair dryer, piano ...)
    11·1 answer
  • Ask the user to enter the number of elements in a list of numbers. Take in the numbers from the user and then output the list th
    6·1 answer
  • Write a program which capitalize every character after full stopin a given sentence
    11·1 answer
  • Assume that there is a class called BankAccountHolder that represents an individual member of a bank. There is also a BankAccoun
    5·2 answers
  • Who distributes IP Address?
    10·1 answer
  • Speeding is one of the most prevalent factors contributing to traffic crashes.
    12·1 answer
  • What are the advantages of customer relationship managment​
    10·1 answer
  • How many total bits are required for a direct mapped cache with 16 KB of data and 4 word blocks Assuming a 32 bit address
    12·1 answer
  • What do you get with brainly points
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!