Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone help me with a UML diagram with my project? Im horrible at these I have two different classes import java.io.*; import java.util.Scanner; public

Can someone help me with a UML diagram with my project? Im horrible at these

I have two different classes

import java.io.*;

import java.util.Scanner;

public class Workout {

@SuppressWarnings("resource")

public static int weightMenu() // Create static method for weightMenu() function and return integer

{

int ch; //Declare integer for choice

Scanner scr = new Scanner(System.in); // Declare object for Scanner reading value

// Display Menu for weight

System.out.println(" 1.Abs");

System.out.println(" 2.Arms");

System.out.println(" 3.Chest");

System.out.println(" 4.Legs");

System.out.println(" 5.Back");

System.out.println(" 6.Shoulders");

System.out.print(" Enter Your Choice: ");

ch = scr.nextInt(); // read choice

return ch; // return choice

}

@SuppressWarnings({ "resource" })

public static int cardioMenu() // Create static method for cardioMenu() function and return integer

{

int ch; // Declare integer for choice

Scanner scr = new Scanner(System.in); // Declare object for Scanner reading value

// Display Menu for cardio

System.out.println(" 1.HIIT");

System.out.println(" 2.Steady State");

System.out.print(" Enter Your Choice: ");

ch = scr.nextInt(); // read choice

return ch; // return choice

}

@SuppressWarnings("resource")

public static void main(String[] args) throws Exception // declare main() function and throw exception for reading

// file

{

BufferedReader rd; // Declare BufferedReader Object rd

int ch; // Declare integer choice

String s; // Delcare String s for reading file content

Scanner in = new Scanner(System.in); // Delcare object for scanner reading value

while (true) // Create infinity while loop until exit program

{

// Display Menu

System.out.println("1\t Cardio");

System.out.println("2\t Weight Lifting");

System.out.println("3\t EXIT");

System.out.print("Please enter your choice:");

// Get user's choice

int choice = in.nextInt();

// Display the title of the chosen module

switch (choice) {

case 1:

System.out.println("Cardio");

ch = cardioMenu(); // call cardioMenu() method and return value into ch variable

switch (ch) // using switch case read menu values

{

// Create rd Object of BufferedReader class and read specific files

// and create while loop for reading file until end of files and display content

// of files

case 1:

rd = new BufferedReader(new FileReader("HIIT.txt"));

// FileReader fr=new FileReader("f:\\HIIT.txt");

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 2:

rd = new BufferedReader(new FileReader("SteadyState.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

default:

System.out.println("You Enter Wrong Choice!");

} // end of cardioMenu() switch()

break;

case 2:

System.out.println("Weight Lifting");

ch = weightMenu(); // call weightMenu() method and return value into ch variable

switch (ch) // using swithc case read menu values

{

// Create rd Object of BufferedReader class and read specific files

// and create while loop for reading file until end of files and display content

// of files

case 1:

rd = new BufferedReader(new FileReader("Abs.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 2:

rd = new BufferedReader(new FileReader("Arms.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 3:

rd = new BufferedReader(new FileReader("Chest.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 4:

rd = new BufferedReader(new FileReader("Legs.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 5:

rd = new BufferedReader(new FileReader("Back.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

case 6:

rd = new BufferedReader(new FileReader("Shoulders.txt"));

while ((s = rd.readLine()) != null)

System.out.println(s);

break;

default:

System.out.println("You Enter Wrong Choice!");

} // end of weightMenu() switch

break;

case 3:

System.exit(0); // exit from the program

}// end of switch

} // end of while loop

}// end of the main method

}// end of class

import java.io.IOException;

import java.net.URISyntaxException;

import java.nio.file.Files;

import java.nio.file.Paths;

import java.util.ArrayList;

import java.util.List;

public class readfiletester {

// Make sure to place all the below file in the classpath

@SuppressWarnings("serial")

static List fileNames = new ArrayList() {

{

add("Back.txt");

add("Arms.txt");

add("Chest.txt");

add("Legs.txt");

add("Shoulders.txt");

add("Abs.txt");

add("HIIT.txt");

add("SteadyState.txt");

}

};

public static void readFileAndPrint(Integer position) {

try {

Files.lines(

Paths.get(readfiletester.class.getClassLoader().getResource(fileNames.get(position - 1)).toURI()))

.forEach(line -> {

System.out.println(line);

});

} catch (IOException | URISyntaxException e) {

e.printStackTrace();

}

}

}

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

Determine whether the number is rational or irrational. 5/5

Answered: 1 week ago

Question

Does it have at least one-inch margins?

Answered: 1 week ago

Question

Does it highlight your accomplishments rather than your duties?

Answered: 1 week ago