Question

In: Computer Science

Java Project Requirements: 1.Write a Java program that plays a word game with a user. The...

Java

Project Requirements:

1.Write a Java program that plays a word game with a user. The program asks the user questions and then creates a paragraph using the user’s answers.

2.The program must perform the following:

a.Uses a Scanner object to ask the user: (The program asks for no other information)

i.Full Name (First and Last name only) - stores this Full Name in one String object variable.

ii.Age – must be read in as an int.

iii.Profession or expected profession

iv.Name of favorite pet

v.Cost of their first vehicle – must be read in as a double.

b.All input data must be stored in their own variable prior to printing out.

c.Display a paragraph of the programmer’s choosing that contains the following

i.The user’s full name, first name, and last name in separate places in the paragraph, such as James Gosling founded Sun Microsystems. James was a child prodigy. The Gosling family is very proud of James.

ii.The user’s age.

iii.The user’s profession in all uppercase regardless of the case the profession was entered.

iv.The user’s favorite pet’s name in all lower case regardless of the case the name was entered.

v.The total cost of the user’s first vehicle in a rounded two decimal places including the dollar signs. The total cost must include the inputted cost plus a 7.5% sales tax. The sales tax rate is stored as a constant in the program.

vi.A statement in parenthesis stating the total number of characters in the paragraph such as (The above story contained 345 characters)

d.Include javadoc class comment following Project Comment Template on the content page.

3.The project requires one files to be turned in - WordGame.java (the source code of your Word Game programming.

Solutions

Expert Solution

wordgame.java

import java.util.Scanner;
import java.io.*;

public class wordgame
{

public static void main(String[] args)
{
       String fullname,proffesion,fav_pet;
       int age;
       double f_v_cost,tax;
       tax = 7.5;

   Scanner scanner = new Scanner(System.in);
   System.out.println( "Enter fullname (first and last name only): ");
   fullname = scanner.nextLine();
       System.out.println( "Enter age: ");
   age = scanner.nextInt();
   System.out.println( "Enter proffesion: ");
   proffesion = scanner.next();
       System.out.println("Enter name of favourite pet: ");
   fav_pet = scanner.next();
       System.out.println( "Enter Cost of their first vehicle: ");
   f_v_cost = scanner.nextDouble();
               String[] parts = fullname.split(" ");
               String fname = parts[0];
               String lastname = parts[1];
       System.out.println(fullname + " works as " + proffesion + ". " + fname + " was a child prodigy. The " + lastname + " family is very proud of "+fname+".");
       // String ss =;
       System.out.println("Current age of " + fname + " is " + age + "." + " His favourite pet is " + fav_pet.toUpperCase() + ".");
       double tmp = Math.round((f_v_cost + f_v_cost* tax/100.0) * 100.0) / 100.0;
       System.out.println("Cost of his first vehicle is $ " + tmp + ".");
}

}

Sample Output:

Enter fullname (first and last name only):
Joe Root
Enter age:
25
Enter proffesion:
Cricketer
Enter name of favourite pet:
Dog
Enter Cost of their first vehicle:
100000
Joe Root works as Cricketer. Joe was a child prodigy. The Root family is very proud of Joe.
Current age of Joe is 25. His favourite pet is DOG.
Cost of his first vehicle is $ 107500.0.


Related Solutions

1. Write a program that plays a simple dice game between the computer and the user....
1. Write a program that plays a simple dice game between the computer and the user. When the program runs, it asks the user to input an even number in the interval [2..12], the number of plays. Display a prompt and read the input into a variable called ‘plays’ using input validation. Your code must ensure that the input always ends up being valid, i.e. even and in [2..12]. 2. A loop then repeats for ‘plays’ iterations. Do the following...
Write a program in Matlab where the program plays a hot and cold game. The user...
Write a program in Matlab where the program plays a hot and cold game. The user answers two inputs: x=input('what is the x location of the object?') y=input('what is the y location of the object?') You write the program so that the computer plays the game. Pick a starting point. Program Calculates the distance to the object. Program picks another point, calculates the distance to the object. Program knows its at the right spot when the distance is less than...
Write a java program. The program requirements are: the program will let the user input a...
Write a java program. The program requirements are: the program will let the user input a starting number, such as 2.  It will generate ten multiplication problems ranging from 2x1 to 2x10.  For each problem, the user will be prompted to enter the correct answer. The program should check the answer and should not let the user advance to the next question until the correct answer is given to the question being asked currently. After testing a total of 10 multiplication problems,...
Write a Java program that plays the game Rock, Paper, Scissors. The program should generate a...
Write a Java program that plays the game Rock, Paper, Scissors. The program should generate a random choice (Rock, Paper or Scissors) then ask the user to choose Rock, Paper or Scissors. After that the program will display its choice and a message showing if the player won, lost or tied. Next, the program should prompt the user to play again or not. Once the player selects to stop playing the game, the program should print the number of wins,...
Write a Java program that prompts the user to input a word (String). The program must...
Write a Java program that prompts the user to input a word (String). The program must print the reversed word with all consecutive duplicate characters removed. The program must contain the following classes: - The StackX class (you can use the Java Stack class). - The Reverse class which must contain a private data field called “word” of type string, a constructor, and a void method called revNoDup(). The revNoDup() method must reverse the word and remove the consecutive duplicate...
Write a Java program that directs the user to enter a single word (of at least...
Write a Java program that directs the user to enter a single word (of at least four characters in length) as input and then prints the word out in reverse in the pattern shown below (please note that the spaces added between each letter are important and should be part of the program you write): <Sample Output Enter a word (at least four characters in length): cat Word must be at least four characters in length, please try again. Enter...
(JAVA) We will write a program to check the spelling of the word entered by user,...
(JAVA) We will write a program to check the spelling of the word entered by user, using data from a dictionary, which is text file. The program will ask user to enter a word for spell check, and then check in the text file (dictionary.txt) if the word exists. (The dictionary.txt file is provided) If the word exists in text file, the output will be “Word is correctly spelled”. If the word doesn’t exist in the text file, program will...
Write a Java program that lets the user play a game where they must guess a...
Write a Java program that lets the user play a game where they must guess a number between zero and one hundred (0-100). The program should generate a random number between 0 and 100 and then the user will try to guess the number. The program should help the user guess the number (see details below). The program must allow the user five attempts to guess the number. Further Instruction: (a) Declare a variable diff and assign to it the...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input using the Scanner class. First to enter their first name. Then prompts the user to enter their last name. Then prompts the user to enter their city. Then prompts the user to enter their state. Then prompts the user to enter their zip code. Concatenate first name and last name into full_name. Using String Class is optional. Use the String Class to replace zip...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input using the Scanner class. First to enter their first name. Then prompts the user to enter their last name. Then prompts the user to enter their city. Then prompts the user to enter their state. Then prompts the user to enter their zip code.   Concatenate first name and last name into full_name. Using String Class is optional. Use the String Class to replace zip...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT