Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

=+j on to staff their operations in the global marketplace.

Answered: 1 week ago