Question: java program hello please can you add a method called(timer) in my cod that makes the program run only for one minute please Merge it

java program

hello

please can you add a method called(timer) in my cod that makes the program run only for one minute please Merge it with my code and show me the output of the program

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ package week9;

import java.util.Scanner;

/** * * @author Aysegul Erman */ public class MethodExamples { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number: "); int num = input.nextInt(); System.out.println(num + "! is " + factorial(num)); //////////// String longest = getLongest("sea", "ship"); System.out.println("Longest of sea and ship: " + longest); //////////// for (int i = 1; i < 6; i++) drawLineOfStars(i); //drawLineOfStars(1); //drawLineOfStars(2); //drawLineOfStars(3); //drawLineOfStars(4); //drawLineOfStars(5); } public static int factorial(int n){ int result = 1; for (int i = n; i > 1; i--){ result *= i; } return result; } public static String getLongest(String str1, String str2){ if (str1.length() > str2.length()) return str1; else if (str2.length() > str1.length()) return str2; else return ""; } public static void drawLineOfStars(int lenght){ for (int i = 0; i < lenght; i++){ System.out.print("*"); } System.out.println(""); } //* //** //*** //**** //***** }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!