JAVA PROGRAMMING QUESTION
scenario: write a program that will prompt a user for 10 legendary people/characters. After the entries are complete the program will display all 10 characters information.
Requirements:
Create a user-defined class with the fields below:
Create a main-source that will use the user-defined class and do the prompting.
Create get/set methods in your user-defined class and methods in the main-source.
thanks for the question, Here is the simple program in Java.
Let me know for any further help.
===================================================================
import java.util.Scanner;
public class Legends {
private String
firstName;
private String
lastName;
private String
nickName;
private String
role;
private String
origin;
public Legends() {
this.firstName =
"";
this.lastName =
"";
this.nickName =
"";
this.role =
"";
this.origin =
"";
}
public Legends(String
firstName, String lastName, String nickName, String role, String
origin) {
this.firstName = firstName;
this.lastName = lastName;
this.nickName = nickName;
this.role = role;
this.origin = origin;
}
public String getFirstName()
{
return
firstName;
}
public void setFirstName(String
firstName) {
this.firstName = firstName;
}
public String getLastName()
{
return
lastName;
}
public void setLastName(String
lastName) {
this.lastName = lastName;
}
public String getNickName()
{
return
nickName;
}
public void setNickName(String
nickName) {
this.nickName = nickName;
}
public String getRole() {
return
role;
}
public void setRole(String
role) {
this.role = role;
}
public String getOrigin()
{
return
origin;
}
public void setOrigin(String
origin) {
this.origin = origin;
}
@Override
public String toString()
{
return
"Legend: " + getFirstName() + " "
+ getLastName() + ", Origin: " + getOrigin()
+
", Nickname: " + getNickName() + ", Role
Played: " + getRole();
}
public static void
main(String[] args) {
Legends legends[] =
new Legends[10]; // create an array of Legends
type of size 10
Scanner scanner =
new Scanner(System.in);
// loop 10 times to prompt user for details, create object
and store at the index
for
(int count = 0; count <
legends.length; count++) {
String fName, lName, nName, role, origin;
System.out.println("Legend" +
(count + 1));
System.out.print("Enter first name:
");
fName = scanner.nextLine();
System.out.print("Enter last name:
");
lName = scanner.nextLine();
System.out.print("Enter nick name:
");
nName = scanner.nextLine();
System.out.print("Enter role played:
");
role = scanner.nextLine();
System.out.print("Enter origin:
");
origin = scanner.nextLine();
legends[count] = new Legends(fName, lName, nName,
role, origin);
System.out.println();
}
// loop through each object in the array using the getter
method print the details.
for
(int count = 0; count <
legends.length; count++) {
System.out.println("Legend: " +
legends[count].getFirstName() + " " +
legends[count].getLastName() + ", Origin: " +
legends[count].getOrigin() +
",
Nickname: " + legends[count].getNickName() + ",
Role Played: " + legends[count].getRole());
}
}
}
===================================================================
JAVA PROGRAMMING QUESTION scenario: write a program that will prompt a user for 10 legendary people/characters....
JAVA Programming scenario: write a program that will prompt a user for 10 legendary people/characters. After the entries are complete the program will display all 10 characters information. requirements: Create a user-defined class with the fields below: - First - Last - Nickname - Role - Origin Create a main-source that will use the user-defined class and do the prompting. Create get/set methods in your user-defined class and methods in the main-source.
FOR JAVA: Summary: Create a program that stores info on textbooks. The solution should be named TextBookSort.java. Include these steps: Create a class titled TextBook that contains fields for the author, title, page count, ISBN, and price. This TextBook class will also provide setter and getter methods for all fields. Save this class in a file titled TextBook.java. Create a class titled TextBookSort with an array that holds 5 instances of the TextBook class, filled without prompting the user for...
Review the structure type address_t described in Programming Project 5 of Chapter 10. Write a program that will create a binary file of address_t structures by repeatedly prompting the user to enter the IP(internet protocol) address and nickname and writing the address_t structure to the binary file. Create a second program that reads each address_t structure from the binary file and displays it in a readable format on the screen.//////////Here is problem 5 but the part in bold is what...
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to input 10 int numbers from the user...
In Java
2. Array Exercise ( 10 points) Write a Java program that will prompt the user to input a size of an array. Create an array of type int. Ask a user to fill the array. Create a functions sortArray() and mostFrequency(). The sortArray() function will sort number into incrementing order. The sorting function must be implemented from scratch and it must not use any function from the library. Feel free to use any sorting algorithm. The program will...
In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read. Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. The program must be in one file. version1: use a while loop. version2: use a do-while loop. version 3: use a for loop. For each version, use a loop to...
Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. Write a JavaFX GUI application to do the same calculation, and draw the circle. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Write and document your program per class coding conventions. Add an instance variable double radius. Generate...
Write a Java program to meet the following requirements: 1. Prompt the user to enter three strings by using nextLine(). Space can be part of the string). ( Note: your program requires using loop: for-loop, while-loop or do-while-loop to get the input String ) 2. Write a method with an input variable (string type).The method should return the number of lowercase letters of the input variable. 3. Get the number of the lowercase letters for each user input string by...
Java Programming Exercise 9-7 In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of sale, amount of sales tax, and several methods. Add get methods for the invoice number and sale amount fields so their values can be used in comparisons. Next, write a program that declares an array of five Purchase objects and prompt a user for their values. Then, in a loop that continues until a user inputs...
Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...