Question

In Java: Write a program that displays all the cars in the given file (no sorting)....

In Java: Write a program that displays all the cars in the given file (no sorting). Each car property is separated by a tab character: \t

Output width: 15 (make), 25 (model), 5 (year)

Given cars.txt :

make   model   year
Ford   Expedition   2003
Mazda   B-Series   1989
Ford   Freestar   2003
Hyundai   Elantra   2001
Hyundai   Entourage   2008
Chevrolet   Camaro   2011
Chevrolet   Monte Carlo   2006
Chevrolet   Blazer   1996
Chevrolet   Aveo   2005
Chevrolet   Corvette   1999
Mercedes-Benz   E-Class   2006
Dodge   Avenger   1995
Pontiac   Grand Prix   1973
Mitsubishi   Outlander   2011
MINI   Clubman   2011
Suzuki   Aerio   2007
Dodge   Dakota Club   1992
Chevrolet   Astro   2002
Chevrolet   Tahoe   1996
Mitsubishi   Mirage   1994
Porsche   944   1991
Hyundai   Elantra   1994
Mercury   Grand Marquis   1998
Volkswagen   Golf   2001
Jaguar   XJ Series   2005
Toyota   Echo   2005
GMC   Safari   2002
GMC   Sierra 1500   2000
Chevrolet   Cobalt   2005
Jeep   Patriot   2008
Mazda   Navajo   1991
Chevrolet   Malibu   2001
Saab   900   1990
Mercury   Grand Marquis   1998
Hummer   H1   2004
Subaru   Loyale   1993
Jeep   Wrangler   1999
Ford   Mustang   1994
Austin   Mini Cooper S   1963
Mercedes-Benz   M-Class   1998
Jeep   Wrangler   2006
Honda   Civic   1997
Plymouth   Voyager   1994
Ford   Club Wagon   1997
Audi   5000S   1984
Saturn   VUE   2003
Oldsmobile   Achieva   1994
Mercedes-Benz   G55 AMG   2006
Chevrolet   Express 3500   1997
Lexus   ES   1992
Cadillac   Allante   1992
Hyundai   Tiburon   1997
Pontiac   Grand Prix   1965
Ford   Focus   2000
Mitsubishi   Chariot   1987
Chrysler   Prowler   2001
Land Rover   Discovery   2012
Volkswagen   Scirocco   1984

required output:

           Ford               Expedition 2003\n
          Mazda                 B-Series 1989\n
           Ford                 Freestar 2003\n
        Hyundai                  Elantra 2001\n
        Hyundai                Entourage 2008\n
      Chevrolet                   Camaro 2011\n
      Chevrolet              Monte Carlo 2006\n
      Chevrolet                   Blazer 1996\n
      Chevrolet                     Aveo 2005\n
      Chevrolet                 Corvette 1999\n
  Mercedes-Benz                  E-Class 2006\n
          Dodge                  Avenger 1995\n
        Pontiac               Grand Prix 1973\n
     Mitsubishi                Outlander 2011\n
           MINI                  Clubman 2011\n
         Suzuki                    Aerio 2007\n
          Dodge              Dakota Club 1992\n
      Chevrolet                    Astro 2002\n
      Chevrolet                    Tahoe 1996\n
     Mitsubishi                   Mirage 1994\n
        Porsche                      944 1991\n
        Hyundai                  Elantra 1994\n
        Mercury            Grand Marquis 1998\n
     Volkswagen                     Golf 2001\n
         Jaguar                XJ Series 2005\n
         Toyota                     Echo 2005\n
            GMC                   Safari 2002\n
            GMC              Sierra 1500 2000\n
      Chevrolet                   Cobalt 2005\n
           Jeep                  Patriot 2008\n
          Mazda                   Navajo 1991\n
      Chevrolet                   Malibu 2001\n
           Saab                      900 1990\n
        Mercury            Grand Marquis 1998\n
         Hummer                       H1 2004\n
         Subaru                   Loyale 1993\n
           Jeep                 Wrangler 1999\n
           Ford                  Mustang 1994\n
         Austin            Mini Cooper S 1963\n
  Mercedes-Benz                  M-Class 1998\n
           Jeep                 Wrangler 2006\n
          Honda                    Civic 1997\n
       Plymouth                  Voyager 1994\n
           Ford               Club Wagon 1997\n
           Audi                    5000S 1984\n
         Saturn                      VUE 2003\n
     Oldsmobile                  Achieva 1994\n
  Mercedes-Benz                  G55 AMG 2006\n
      Chevrolet             Express 3500 1997\n
          Lexus                       ES 1992\n
       Cadillac                  Allante 1992\n
        Hyundai                  Tiburon 1997\n
        Pontiac               Grand Prix 1965\n
           Ford                    Focus 2000\n
     Mitsubishi                  Chariot 1987\n
       Chrysler                  Prowler 2001\n
     Land Rover                Discovery 2012\n
     Volkswagen                 Scirocco 1984\n
           Ford                   Bronco 1984\n
        Hyundai                   Accent 1996\n
     Volkswagen                   Routan 2012\n
     Volkswagen                     Golf 2003\n
            GMC                  Terrain 2010\n
           Ford                     F150 2009\n
            GMC                   Sierra 2011\n
          Dodge             Ram Van 1500 2000\n
       Chrysler                      300 2009\n
     Oldsmobile                  Achieva 1997\n
     Land Rover                Discovery 2008\n
         Toyota                  4Runner 2002\n
        Porsche                      911 1995\n
         Toyota             Land Cruiser 2002\n
     Land Rover                 Defender 1994\n
      Chevrolet                   Lumina 1997\n
           Audi                       TT 2002\n
       Chrysler           Town & Country 2009\n
         Nissan                 Frontier 2000\n
         Toyota                   Tercel 1997\n
          Buick                  Riviera 1997\n

Ford   Bronco   1984
Hyundai   Accent   1996
Volkswagen   Routan   2012
Volkswagen   Golf   2003
GMC   Terrain   2010
Ford   F150   2009
GMC   Sierra   2011
Dodge   Ram Van 1500   2000
Chrysler   300   2009
Oldsmobile   Achieva   1997
Land Rover   Discovery   2008
Toyota   4Runner   2002
Porsche   911   1995
Toyota   Land Cruiser   2002
Land Rover   Defender   1994
Chevrolet   Lumina   1997
Audi   TT   2002
Chrysler   Town & Country   2009
Nissan   Frontier   2000

Homework Answers

Answer #1
import java.io.*;
public class carExpert
{
 public static void main(String[]args)throws IOException
 {
    FileReader fr = new FileReader("cars.txt");
    BufferedReader br = new BufferedReader(fr);
    while(br.readLine()!= null)
    { 
      String readCars = br.readLine();
      String str[] = readCars.split("\t");
      for( int i = 1; i <= str.length; i++)
      { 
        System.out.println(str[i]+"\t\t\t"+str[i+1]+" "+str[i+2]);

      }
    }
  }
}
     
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Each year a market research company surveys new car owners 90 days after they purchase their...
Each year a market research company surveys new car owners 90 days after they purchase their cars. This data is used to rate auto brands (such as Toyota and Ford) on quality and customer satisfaction. Suppose the following were the quality rating and satisfaction scores for all 33 brands sold in the United States. Brand Quality Rating Satisfaction Rating Acura 86 822 Audi 111 832 BMW 113 845 Buick 114 802 Cadillac 111 818 Chevrolet 111 789 Chrysler 122 748...
The car dealer has all of their inventory housed in the array seen below. Scroll down...
The car dealer has all of their inventory housed in the array seen below. Scroll down past the data to find out how you can help the car dealer. let inventory = [ { id: 1, car_make: "Lincoln", car_model: "Navigator", car_year: 2009 }, { id: 2, car_make: "Mazda", car_model: "Miata MX-5", car_year: 2001 }, { id: 3, car_make: "Land Rover", car_model: "Defender Ice Edition", car_year: 2010 }, { id: 4, car_make: "Honda", car_model: "Accord", car_year: 1983 }, { id: 5,...
When will the world reach zero growth rate? 1964 5.068 1965 5.05     1966 4.997 2007...
When will the world reach zero growth rate? 1964 5.068 1965 5.05     1966 4.997 2007 2.553 1967 4.974 2008 2.542 1968 4.92 2009 2.524 1969 4.85 2010 2.508 1970 4.771 2011 2.492 1971 4.662 2012 2.484 1972 4.533 2013 2.468 1973 4.405 2014 2.461 1974 4.285 2015 2.452 1975 4.155 2016 2.439 1976 4.041 1977 3.94 1978 3.849 1979 3.781 1980 3.722 1981 3.666 1982 3.637 1983 3.603 1984 3.572 1985 3.542 1986 3.505 1987 3.461 1988 3.406 1989...
While Florida obviously has the upper hand in terms of production, California claims that they have...
While Florida obviously has the upper hand in terms of production, California claims that they have the upper hand in terms of productivity. test this hypothesis Year CALIFORNIA FLORIDA 1978 226 290 1979 199 287 1980 320 358 1981 357 301 1982 233 225 1983 429 260 1984 274 246 1985 299 247 1986 309 324 1987 335 319 1988 342 363 1989 332 377 1990 408 276 1991 143 360 1992 371 315 1993 363 381 1994 344 341...
test the hypothesis that Florida has been the dominant orange-producing state in the US historically (e.g....
test the hypothesis that Florida has been the dominant orange-producing state in the US historically (e.g. conduct an upper tailed test for Florida compared to the total US values excluding Florida (column F)). Assume a z-distribution Year FLORIDA Non-Florida 1970 137.7 48.07 1971 142.3 47.13 1972 137 54.45 1973 169.7 54.96 1974 165.8 50.41 1975 173.3 64.51 1976 181.2 61.58 1977 186.8 56.15 1978 167.8 52.32 1979 164 46.6 1980 206.7 66.93 1981 172.4 72.18 1982 125.8 50.89 1983 139.6...
1. It has been suggested that global warming may increase the frequency of hurricanes. The table...
1. It has been suggested that global warming may increase the frequency of hurricanes. The table given below shows the number of major Atlantic hurricanes recorded annually before and after 1990. before 1995 after 1995 year # of storms year # of storms 1976 2 1996 6 1977 1 1997 1 1978 2 1998 3 1979 2 1999 5 1980 2 2000 3 1981 3 2001 4 1982 1 2002 2 1983 1 2003 3 1984 1 2004 6 1985...
Calculate the contemporaneous correlation coefficient between M3 velocity and real GDP. Based on this correlation coefficient,...
Calculate the contemporaneous correlation coefficient between M3 velocity and real GDP. Based on this correlation coefficient, is velocity procyclical, countercyclical, or acyclical? STATISTICS CANADA FED. RESERVE BANK OF ST.LOIUS DATABASE v62295562 NOMINAL GDP GDP inplicit price deflator M3 Canada Quarterly v62295562 CANGDPDEFQISMEI MABMM301CAQ189S Q1 1981 354784 42.6981111563270 204311333333.333000 Q2 1981 366788 43.6610414619373 207984000000.000000 Q3 1981 371560 44.6289982488560 216848000000.000000 Q4 1981 375352 45.2908438640580 218082333333.333000 Q1 1982 381676 46.6083169696692 217479333333.333000 Q2 1982 385140 47.5798005714623 219886000000.000000 Q3 1982 388116 48.3739589515175 222330333333.333000 Q4 1982...
Calculate the contemporaneous correlation coefficient between M3 monetary aggregate and real GDP. Is M3 money procyclical,...
Calculate the contemporaneous correlation coefficient between M3 monetary aggregate and real GDP. Is M3 money procyclical, countercyclical, or acyclical? STATISTICS CANADA FED. RESERVE BANK OF ST.LOIUS DATABASE v62295562 NOMINAL GDP GDP inplicit price deflator M3 Canada Quarterly v62295562 CANGDPDEFQISMEI MABMM301CAQ189S Q1 1981 354784 42.6981111563270 204311333333.333000 Q2 1981 366788 43.6610414619373 207984000000.000000 Q3 1981 371560 44.6289982488560 216848000000.000000 Q4 1981 375352 45.2908438640580 218082333333.333000 Q1 1982 381676 46.6083169696692 217479333333.333000 Q2 1982 385140 47.5798005714623 219886000000.000000 Q3 1982 388116 48.3739589515175 222330333333.333000 Q4 1982 392160 49.3332837976593 224303666666.667000...
Problem:: The number of Starbucks stores grew after they first opened. The number of stores from...
Problem:: The number of Starbucks stores grew after they first opened. The number of stores from 1990-2011, as reported on their corporate website is shown in the chart below.. Carefully plot the data. You should be able to see that the data is NOT linear, but actually exponential. Year Number of Starbucks stores Year Number of Starbucks stores 1990 84 2001 4709 1991 116 2002 5886 1992 165 2003 7225 1993 272 2004 8569 1994 425 2005 10241 1995 677...
Estimate the following simple regression models (using the given data) Male Labor Participation = β0 +...
Estimate the following simple regression models (using the given data) Male Labor Participation = β0 + β1*Average Hourly Earnings + ei Female Labor Participation = β0 + β1*Average Hourly Earnings + ei Interpret the estimated parameters of the above two regression models Year CLFPRM CLFPRF UNRM UNRF AHE 1980 77.4 51.5 6.9 7.4 6.8 1981 77.0 52.1 7.4 7.9 7.4 1982 76.6 52.6 9.9 9.4 7.9 1983 76.4 52.9 9.9 9.2 8.2 1984 76.4 53.6 7.4 7.6 8.5 1985 76.3...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT