Continue with the object keyboard from Self-Test Exercise 16. Consider the
following input:
What values will the following code assign to the variables word1 and word2?
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
Starting out with Visual C# (4th Edition)
- Write a java program Take two test Strings (StrFirstName and StrLastName) as input from User and Demonstrate the use of at least ten String Class Methods. (Use your own first and last name). (Source code + Output). First Name: Syeda Last Name: Humnaarrow_forwardImplement the below pseudo-code in a Java program using a while loop and aswitch-case statement. The program should be well structured, and the taskperformed under each option (at least options 'b' to 'e') should be implementedas a separate method.NOTE: The Scanner class does not have a method to input a character. Inorder to read a character from the keyboard, use one of the following methods(after declaring the Scanner object):static Scanner kb = new Scanner(System.in);1. char ch = kb.nextLine().charAt(0); OR2. char ch = kb.nextLine().toLowerCase().charAt(0);where kb is a Scanner class object.The second method above also converts the input to lowercase, which is oftenuseful. Though these methods allow the user to input more than one characteron the input line, the rest of the line (after capturing the first character withcharAt(0)) is discarded.If you also want to ignore the leading spaces before the first character thenuse:1. char ch = kb.nextLine().trim().charAt(0); OR2. char ch =…arrow_forwardIN JAVA Trace the evaluation of the expressions and give the resulting values. (Make sure to give a value of the appropriate type, such as including a .0 at the end of a double result. If the result is a String, enclose the String in double quotes.) 8 / 5 + 13 % 2 / 3.0 10 / 4 / 2 (12 + (8 * -1) - 3) / 4 * 2 5 * 7 % 4 + “Hi” + 4 - 3arrow_forward
- Write a program that reads a mile in a double valuefrom the console, converts it to kilometers, and displays the result. The formulafor the conversion is as follows:1 mile = 1.6 kilometersHere is a sample run:learn from examplesEnter miles: 96 [ENTER]96 miles is 153.6 kilometersarrow_forwardPlease help me solve this with java .... just the HangMan HangMan instruction class : • HangMan is a game in which a player tries to guess a word based on a given hint. For example, if the given hint is “movie”, then the player must guess a movie name. If the given hint is a “country”, then the player must guess a country name, and so on.• The game starts by showing a message on the screen that shows the hint and all letters in the word but obscured as dashes (-). Then, the game will allow the player to guess 5 letters. If the player gives a letter that actually exists in the word, then this letter will be revealed. Afterwards, the game will ask the player to give the answer. If the given answer is correct, then the game will show a message that the player has won 5 points. Otherwise, the game will show a message that the player has lost. Below is one possible game scenario, in which the word is “iron man”, and the hint is “movie”. Note that the text in green color is the…arrow_forwardWrite a program that displays the classic BINGO game, displays a BINGO card (5x5 square), and tests the bingo card for a winner via 2 usersarrow_forward
- Write a java program that will create a Deck object and shuffle the deck. Then, you will draw ten cards from the deck and perform selection statements that carry out the following: If the card is red, then print “Card is red” to the screen. Otherwise, print “Card is black” to the screen. If the card is a picture card, print “That's a picture card”. If the card is an ace, print “That's an Ace”. If the card has a value less than 6, print “Card has a small value”. If the card has a value between 6 and 10 (inclusive), print “Card has a large value”. In the source code, write an algorithm for the program in a comment block. Also, in a comment block, paste the results of running your program. Print out and turn in the completed source code with those comments.arrow_forwardAnswer with a given JAVA question below. Consider the following code: public class Quiz{ public String name; public double totalPoints; public String getName() { return this.name; } public double getTotalPoints() { return this.totalPoints; } } Based on the Java code, explain where information hiding is being violated, why it is considered a violation, and how a programmer should fix the violation.arrow_forwardWrite a program that opens a window that contains a button. The button is labled with "0" (zero). With every click on the button, the number in its label increments by 1.(use Java)arrow_forward
- Write a program that plays a guessing game with the user. The user should pick a letter, and the computer should try to guess the letter. After each guess, the user should tell the computer whether its guess was too high or too low. With this information, the computer should be able to guess the letter within five tries. The user should be able to give whole words or single upper or lower case letters as responses. c++arrow_forwardImplement the design of the Patient class so that the following output is produced:[For BMI, the formula is BMI = weight/height^2, where weight is in kg and height inmeters] Driver Code # Write your code herep1 = Patient("A", 55, 63.0, 158.0)p1.printDetails()print("====================")p2 = Patient("B", 53, 61.0, 149.0)p2.printDetails() Outputarrow_forwardI need help adding a new line at the end of the output string here is my Java code, and it is all correct except at the end of the output it is requiring a newline after. import java.util.Scanner; public class LabProgram { //method drivingCost definition public static double drivingCost(double drivenMiles,double milesPerGallon,double dollarsPerGallon){ double yourValue; yourValue = (drivenMiles/milesPerGallon)*dollarsPerGallon; System.out.printf("%.2f ", yourValue); return yourValue;} public static void main(String[] args) { double milesPerGallon; double dollarsPerGallon; Scanner sc = new Scanner(System.in); milesPerGallon = sc.nextDouble(); dollarsPerGallon = sc.nextDouble(); drivingCost(10, milesPerGallon, dollarsPerGallon); drivingCost(50, milesPerGallon, dollarsPerGallon); drivingCost(400, milesPerGallon, dollarsPerGallon); }}arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education