Question

In: Computer Science

Write a program in JAVA to create the move set of a Pokémon, and save that...

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

Solutions

Expert Solution

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:

=====


Related Solutions

java program: Please save the program with the name ‘Palindrome.java’ Write a method which return true...
java program: Please save the program with the name ‘Palindrome.java’ Write a method which return true if the string parameter is a palindrome. This is the output example: Lets check if a string is a palindrom Please give me a string: abc No, its not a Palindrom Lets check if a string is a palindrom Please give me a string: noon Yes, its a Palindrom
Create a JAVA program to find the mean and standards deviation of a large set of...
Create a JAVA program to find the mean and standards deviation of a large set of data by breaking it down into smaller sets and use threads to process each smaller data set. The simulation will use only 3 threads, and each data set will be at most 100 integers. Create two classes, namely HadoopSim class for the thread tasks and HadoopDriver class for the main routine. (Then the main routine must gather up the results of each thread and...
Write a program that takes a set of m numbers up to size n and save...
Write a program that takes a set of m numbers up to size n and save them in an array. The program then allows you to search for any number in the array with O(1).
Write a Java program to create an array of a specific size (which is an input...
Write a Java program to create an array of a specific size (which is an input from the user) and fill it with random numbers between 1 and 100. Then sort the array and count how many of these numbers are originally at sorted position. Display that original array, the sorted array, and the count (number of elements originally at sorted position).
Write a program in java that does the following: Create a StudentRecord class that keeps the...
Write a program in java that does the following: Create a StudentRecord class that keeps the following information for a student: first name (String), last name (String), and balance (integer). Provide proper constructor, setter and getter methods. Read the student information (one student per line) from the input file “csc272input.txt”. The information in the file is listed below. You can use it to generate the input file yourself, or use the original input file that is available alone with this...
Please use Java language with comments! Thanks! Write a program that will display multiple dots move...
Please use Java language with comments! Thanks! Write a program that will display multiple dots move across the Frame and randomly change direction when they hit the edge of the screen. Do this by creating a Dot class and making each dot an object of that class. You may reuse code written in class for this part of the assignment. Create a subclass of the Dot class called PlayerDot that is controlled by the player through keyboard input (arrow keys)...
QUESTION Write the main while loop for a Java program that processes a set of data...
QUESTION Write the main while loop for a Java program that processes a set of data as follows: Each line of the input consists of 2 numbers representing a quantity and price. Your loop should: 1. Read in the input 2. Calculate the tax. Tax will be 8.875% of price and will only be applicable if price is more than 110. Calculate the new price which is the price plus tax. 3. Calculate the final price by multiplying quantity by...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to have the program print your name, favorite color, and three hobbies to a new text file called “AllAboutMe” using PrintStream. Submit code.
write the program in java. Demonstrate that you understand how to use create a class and...
write the program in java. Demonstrate that you understand how to use create a class and test it using JUnit Let’s create a new Project HoursWorked Under your src folder, create package edu.cincinnatistate.pay Now, create a new class HoursWorked in package edu.cincinnatistate.pay This class needs to do the following: Have a constructor that receives intHours which will be stored in totalHrs Have a method addHours to add hours to totalHrs Have a method subHours to subtract hours from totalHrs Have...
Write a Java program to process the information for a bank customer.  Create a class to manage...
Write a Java program to process the information for a bank customer.  Create a class to manage an account, include the necessary data members and methods as necessary.  Develop a tester class to create an object and test all methods and print the info for 1 customer.  Your program must be able to read a record from keyboard, calculate the bonus and print the details to the monitor.  Bonus is 2% per year of deposit, if the amount is on deposit for 5 years...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT