Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following input file best-selling-albums.dat, write a program the read

ID: 3843910 • Letter: G

Question

Given the following input file best-selling-albums.dat, write a program the reads in the input file and prints out the name of the album followed by the word Amazing for each album whose sales were over 50 millions, the word Sweet for sales between 45 and 50 millions and the word Good for all others. best-selling-albums.dat (Album Name, Copies Sold in millions) Thriller, 65 The Dark Side of the Moon, 45 Eagles Greatest Hits, 42 Back in Black, 40 Saturday Night Fever, 40 Rumours, 40 The Bodyguard, 40

Explanation / Answer

Bestsellingalbum.txt

----------------------------

Thriller, 50
The Dark side of the Moon, 45
Eagels Greatest Hits,42
Back in Black 40
Saturday Night Fever,40
Rumours,40
The Bodyguard,40

BestsellingProperty.java

---------------------------------

package venkanna;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class BestsellingProperty
{
   public static void main(String[] args)
   {
       String line = null;
       String[] arr2 = new String[7];
       int count = 0, i = 0;
       File file = new File("D:\New folder\Bestsellingalbum.txt");
       try
       {
           Scanner sc = new Scanner(file);
           BufferedReader br = new BufferedReader(new FileReader(file));
           while (sc.hasNextLine())
           {
               line = sc.nextLine();
               String arr[] = line.split(",");
               for (String word : arr)
               {
                   ++count;
                   arr2[i] = word;
                   if (count == 2)
                   {
                       i = 0;
                       int result = Integer.parseInt(word.trim());
                       System.out.print("The Album Name is:"+arr[i] +"of "+result+":");
                       if (result >= 50)
                       {
                           System.out.println("Amazing");
                       }
                       else if (result >= 45 && result <= 50)
                       {
                           System.out.println("Sweet");
                       }
                       else
                       {
                           System.out.println("Good");
                       }

                       count = 0;
                       i++;
                   }
                   ++i;
               }
           }
           sc.close();
       }
       catch (FileNotFoundException e) {
           e.printStackTrace();
       }

   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote