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

C++ Assignment Introduction You work for a disc jockey who has asked you to obta

ID: 3860031 • Letter: C

Question

C++ Assignment

Introduction You work for a disc jockey who has asked you to obtain a list of the top 1000 must listen to songs1 and write a program that allows her to list the songs according to Theme, Title, Artist, Year. In addition, from the list she can select a particular song to Be played on “Spotify" (NOTE: the "playing on Spotify" is sketchy and may not work correctly on your computer but as long as the code to do so is correct then you will get full credit). To be considered correct, your program will need to implement several functions described next. 1. COLUMNINDEX GetColumlndex(...) This function takes a string as an argument (which is one of the column names in the 1000songs.csv file) and returns an enumeration which needs to be used in a branching statement in your main routine to determine what data to prompt for next. The enumeration type is defined as: enum COLUMNINDEX THEME, TITLE, ARTIST, YEAR, SPOTIFYURL) void GetColumValue...).- This function takes a file stream variable (the open 1000songs.csv file and returns as string variables the fields Theme, Title, Artist, and Year from one row (record) of the file. One of the reasons for this function is that the data in the file may need to be massaged a little (i.e. case sensitivity issues) so that it can be compared to user input, and this is a good place to do that. 2. 3. string GetSpotifyURL...)- This function takes the number of the line (record) in the file (the particular row of data in the file) as an argument and returns the "Spotify" URL (please visit this link: http://en.wikipedia.org/wiki/Spotify . This Spotify URL is used in the function LaunchSpotify described below. NOTE: Not all rows of data in the 1000songs.csv a link so your program will have to handle an empty Spotify URL string accordingly) 4. void LaunchSpotify...) This function takes the Spotify URL and attempts to launch a web browser and play the song. The reason I say attempt is because sometimes it works and sometimes it doesn't. The reasons are vast such as what web browser is confgured as the default, user privileges, the data itself, and the data is kind of "dirty", and other things. But implement it anyhow. if you discover a better method indicate it in your program and I will give you some extra points. In this void LaunchSpotify(..) function, to launch your default Web browser and go to the page indicated by the Spotify URL , call the Windows function ShellExecuteA(NULL, NULL, stru RL.c stro. NULL, NULL, SW SHOWNORMAL); NOTE: "strURL.c_str)" is the Spotify URL passed into this.

Explanation / Answer

/*

Calculate Circle Area using Java Example

This Calculate Circle Area using Java Example shows how to calculate

area of circle using it's radius.

*/

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class CalculateCircleAreaExample {

  public static void main(String[] args) {

  

  int radius = 0;

  System.out.println("Please enter radius of a circle");

  

  try

  {

  //get the radius from console

  BufferedReader br = newBufferedReader(new InputStreamReader(System.in));

radius =Integer.parseInt(br.readLine());

  }

  //if invalid value was entered

  catch(NumberFormatException ne)

  {

  System.out.println("Invalid radius value" + ne);

  System.exit(0);

  }

  catch(IOException ioe)

  {

  System.out.println("IO Error :" + ioe);

  System.exit(0);

  }

  

  /*

* Area of a circle is

* pi * r * r

* where r is a radius of a circle.

*/

  

  //NOTE : use Math.PI constant to get value of pi

  double area = Math.PI * radius * radius;

  

  System.out.println("Area of a circle is " +area);

  }

}

/*

Output of Calculate Circle Area using Java Example would be

Please enter radius of a circle

19

Area of a circle is 1134.1149479459152

*/