Computer scienceProgramming languagesGolangPackages and modulesStandard libraryTime package

Time scheduling

Cooking Timer

Report a typo

Your task is to create a simple cooking timer application in Go. The program should allow a user to set a timer for a specific cooking task and notify them when the time is up.

Requirements:

  1. The program should prompt the user to enter the cooking time in seconds.
  2. After the user sets the timer, the program should display a countdown timer that updates every second, indicating the time remaining.

Sample Input 1:

5

Sample Output 1:

Enter cooking time (in seconds): 
Cooking timer started!
Time remaining: 5 seconds
Time remaining: 4 seconds
Time remaining: 3 seconds
Time remaining: 2 seconds
Time remaining: 1 seconds
Cooking is complete. Enjoy your meal!
True cooking true
Write a program in Go
package main

import (
"fmt"
"time"
)

// Do not delete this block!
var (
_ = fmt.Println
_ = time.Time{}
)

func userCreatesTimer() int {
// Where would you store seconds
fmt.Println("Enter cooking time (in seconds): ")
return 0
}

func cooking(cookingTimeSeconds int) {
fmt.Println("Cooking timer started!")
// Cooking logic that counts down the timer
fmt.Printf("Time remaining: %d seconds\n", _)
}

Create a free account to access the full topic