Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

Perform the indicated operations. m3m + 5m - 3 m - 1

Answered: 1 week ago

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago

Question

a valuing of personal and psychological privacy;

Answered: 1 week ago