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 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...
C Program and pseudocode for this problem. Write a C program that plays the game of...
C Program and pseudocode for this problem. Write a C program that plays the game of "Guess the number" as the following: Your program choose the number to be guessed by selecting an integer at random in the rang of 1 to 1000. The program then asks the use to guess the number. If the player's guess is incorrect, your program should loop until the player finally gets the number right. Your program keeps telling the player "Too High" or...
Program Created Last Week: #Program plays a guessing the number game with the user. #Importing random...
Program Created Last Week: #Program plays a guessing the number game with the user. #Importing random number with min number being 1 and max being 10 import random min_number = 1 max_number = 10 rand = random.randint(min_number, max_number) #Prints the header, welcoming the user print("Welcome to the Guess My Number Program!") while (True): #While loop, comparing the users guessed number with the random number. #If it matches, it will say you guessed it. guess = eval(input("Please try to guess my...
JAVA Project: Student Major and status Problem Description: Write a program that prompts the user to...
JAVA Project: Student Major and status Problem Description: Write a program that prompts the user to enter two characters and displays the major and status represented in the characters. The first character indicates the major and the second is a number character 1, 2, 3 or 4, which indicates whether a student is a freshman, a sophomore, junior or senior. Suppose the following characters are used to denote the majors: M: Mathematics C: Computer Science I: Information Technology Here is...
Java Program 1. Write a program that asks the user: “Please enter a number (0 to...
Java Program 1. Write a program that asks the user: “Please enter a number (0 to exit)”. Your program shall accept integers from the user (positive or negative), however, if the user enters 0 then your program shall terminate immediately. After the loop is terminated, return the total sum of all the previous numbers the user entered. a. What is considered to be the body of the loop? b. What is considered the control variable? c. What is considered to...
This is Java In this problem we will write a program that asks the user to...
This is Java In this problem we will write a program that asks the user to enter a) The user's first name and b) a series of integers separated by commas. The integers may not include decimal points nor commas. The full string of numbers and commas will not include spaces either, just digits and commas. An example of valid input string is:        7,9,10,2,18,6 The string must be input by the user all at once; do not use a loop...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT