Answered

Write code to read a list of song names and durations from input. Input first receives a song name, then the duration of that song. Input example: Time 424 Money 383 quit.

Answer :

KvngDami

Answer:

Explanation:

public class SongList

{

public static void main(String [] args)

{

   scanner input = new Scanner(System.in)

   System.out.Println ("Do you want to run again:\n(1 for yes and 2 for  no ")

   Int run = in.nextInt

  Do

  {

  System.out.Println ("Enter song name:\n ")

  String songName = in.nextString;

  System.out.Println ("Enter song duration:\n ")

  String songDuration = in.nextString;

  }

  while( run == 1)

}

}

MrRoyal

The program illustrates the use of while loops

The program in Python where comments are used to explain each line is as follows:

#This initializes an empty string

quit = ""

#The following loop is repeated until the user quits

while quit != "y" and quit!="Y":

   #This gets input for the song name

   songName = input()

   #This gets input for the song duration

   duration = int(input())

   #This asks if the user wants to quit

   quit = input("Quit? Y/N: ")

The program will run unless the user quits by pressing Y or y

See attachment for sample run

Read more about similar programs at:

https://brainly.com/question/15649856

${teks-lihat-gambar} MrRoyal

Other Questions