In: Computer Science
Write a program in JAVA to create the move set of a Pokémon, and save that move set to a file. This program should do the following:
Ask for the pokemon’s name.
Ask for the name, min damage, and max damage of 4 different moves.
Write the move set data into a file with the pokemon’s name as the filename.
The format of the output file is up to you, but keep it as simple as possible
Code:
====
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class PokemonData {
public static void main(String[] args) throws
FileNotFoundException {
Scanner sc = new
Scanner(System.in);
System.out.print("Enter pokemon
name: ");
String name = sc.nextLine();
PrintWriter pw = new
PrintWriter(new File(name+".txt"));
int i=0;
pw.write("Minimum
Maximum\n");
while(i<4) {
System.out.print("Enter minimum damage of move#"+(i+1)+": ");
int min =
Integer.parseInt(sc.nextLine());
System.out.print("Enter maximum damage of move#"+(i+1)+": ");
int max =
Integer.parseInt(sc.nextLine());
pw.write(min
+"\t\t\t"+max+"\n");
i++;
}
System.out.println("Data written to
the file "+name+".txt successfuly.");
pw.close();
sc.close();
}
}
output:
=====