Question: tasked with writing a program for a machine that high five the user. The input file moves.txt contains a series of 5 words, LEFT or

tasked with writing a program for a machine that high five the user.

The input file "moves.txt" contains a series of 5 words, "LEFT" or "RIGHT". Students will be tasked with building a High-Five class, made up of 2 Strings, one from the user and one from the file. In order for a high five to successfully land, the user will input LEFT or RIGHT and it will have to match the string scanned from the file.

Make sure to keep count of how many high-fives make impact with each other.

Please use the template provide below!

package f2_template;

import java.io.File; import java.util.Scanner;

/** * * @author school */ public class F2_Template {

/** * @param args the command line arguments */ public static void main(String[] args) { //INTIALIZE SCANNER FOR FILE INPUT. ADD TRY/CATCH Scanner scnr = null; File inFile = new File("moves.txt"); try{ scnr = new Scanner(inFile); } catch(Exception e){ System.out.println("Error. File not found."); } //INTIALIZE SCANNER FOR USER INPUT AND COUNT //USER IS PROMPTED TO MAKE 5 CHOICES OF "LEFT" OR "RIGHT" System.out.println("Your input file has 5 high fives. See how many you hit in a Row!"); System.out.println("Enter LEFT or RIGHT"); while (scnr.hasNext()) { //STUDENTS WILL TAKE IN A STRING FROM THE FILE AND A STRING FROM THE USER //AND BUILD A HIGH-FIVE CLASS USING THOSE STRINGS //IF THE HANDS MATCH, COUNT INCREASES BY ONE. //OUTPUT IF USER HIT OR MISS THE HIGH-FIVE } //OUPUT USERS COUNT (AFTER WHILE LOOP)

} }

package f2_template;

/** * * @author school */ public class high_Five { //STUDENTS WILL ADD THE MOVES AS ATTRIBUTES

private String userHand; private String fileHand;

//BUILD CONSTRUCTOR //COMPARES ATTRIBUTES AND RETURNS BOOLEAN TRUE OR FALSE WHEN THEY MATCH }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Certainly Lets proceed with filling in your Java code to implement the desired functionality as outlined in the task description Well create the HighF... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!