-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlbum.java
More file actions
36 lines (33 loc) · 1.35 KB
/
Album.java
File metadata and controls
36 lines (33 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
/*
* The code asks user to enter some data and then the code converts this data from string, to more suitable data types.
* Finally all data is outputed.
*/
public class Album {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
try{
System.out.print("Enter the title: ");
String title = scanner.nextLine();
System.out.print("Enter the artist: ");
String artist = scanner.nextLine();
System.out.print("Enter the shop section: ");
char shopSection = scanner.nextLine().charAt(0);
System.out.print("Enter number of tracks: ");
int numTracks = Integer.parseInt(scanner.nextLine());
System.out.print("Enter if in stock: ");
boolean inStock = Boolean.parseBoolean(scanner.nextLine());
System.out.print("Enter the price: ");
double price = Double.parseDouble(scanner.nextLine());
System.out.println(title);
System.out.println(artist);
System.out.println(shopSection);
System.out.println(numTracks);
System.out.println(inStock);
System.out.println(price);
}catch(NumberFormatException exeption){
System.out.println("Wrong format");
}
scanner.close();
}
}