Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Experience the ease of finding quick and accurate answers to your questions from professionals on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

write code to read a list of song durations and song names from input. for each line of input, set the duration and name of currsong. then add currsong to songslist. input first receives a song duration, then the name of that song (which you can assume is only one word long). input example: 424 Time
383 Money
-1
In C++
#include
#include
#include
using namespace std;
class Song {
public:
void SetDurationAndName(int songDuration, string songName) {
duration = songDuration;
name = songName;
}
void PrintSong() const {
cout << duration << " - " << name << endl;
}
int GetDuration() const { return duration; }
string GetName() const { return name; }
private:
int duration;
string name;
};
int main() {
vector myPlaylist;
Song currSong;
int currDuration;
string currName;
unsigned int i;
cin >> currDuration;
while (currDuration >= 0) {
// code here
cin >> currDuration;
}
for (i = 0; i < myPlaylist.size(); ++i) {
currSong = myPlaylist.at(i);
currSong.PrintSong();
}
return 0;
}


Sagot :

Python is a general-purpose language, which means it may be used to make many various types of applications and isn't tailored for any particular issues.

What is meant by Python?

Python is a popular computer programming language used to create software and websites, automate processes, and analyze data. Python is a general-purpose language, which means it may be used to make many various types of applications and isn't tailored for any particular issues.

Guido van Rossum created Python, an interpreted, object-oriented, high-level programming language with dynamic semantics. It was first made available in 1991. The name "Python" is a tribute to the British comedy group Monty Python and is meant to be both simple and entertaining.

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.

To learn more about Python refer to:

https://brainly.com/question/26497128

#SPJ4

View image tutorconsortium127