// This program calculates how much a song makes on different streaming services
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
int main()
{
int choice;
int views;
string artist;
string song;
// Choice= streaming selection/ num= the amount of views the song gets.
// This is where the menu is displayed
cout << "Which streaming service will you use to upload your song? " << endl;
cout << " 1: TIDAL " << endl;
cout << " 2: Amazon " << endl;
cout << " 3: Apple Music " << endl;
cout << " 4: Spotify " << endl;
cout << " 5: Youtube " << endl;
cout << " Please enter a number (1-5) to select which service you want to upload to. " << endl;
cin >> choice;
// TIDAl= 0.0125, Amazon= 0.00402, AM(Apple Music)= 0.00737, Spotify= 0.00437, Youtube= 0.00069
double Tidal= 0.0125, Amazon= 0.00402, AM= 0.00737, Spotify= 0.00437, Youtube= 0.00069;
// The lines below are the calcualtions based on the different choices the user imputs.
// Each of the choice options below as the user for the name of the artist, the name of the song, and how many views it has.
if (choice == 1)
{
cout << " What is the Artist's name? " << endl;
cin >> artist;
cout << " What song from the artist do you want to upload? " << endl;
cin >> song;
cout << " How many views does the song have? " << endl;
cin >> views;
cout << "Song Name: " << song << endl;
cout << "Artist's Name: " << artist << endl;
cout << "Streaming Service: " << "TIDAL" << endl;
cout << "Money Made $ " << (Tidal * views) << endl;
}
if (choice == 2)
{
cout << " What is the Artist's name? " << endl;
cin >> artist;
cout << " What song from the artist do you want to upload? " << endl;
cin >> song;
cout << " How many views does the song have? " << endl;
cin >> views;
cout << "Song Name: " << song << endl;
cout << "Artist's Name: " << artist << endl;
cout << "Streaming Service: " << "Amazon" << endl;
cout << "Money Made $ " << (Amazon * views) << endl;
}
if (choice == 3)
{
cout << " What is the Artist's name? " << endl;
cin >> artist;
cout << " What song from the artist do you want to upload? " << endl;
cin >> song;
cout << " How many views does the song have? " << endl;
cin >> views;
cout << "Song Name: " << song << endl;
cout << "Artist's Name: " << artist << endl;
cout << "Streaming Service: " << "Apple Music" << endl;
cout << "Money Made $ " << (AM * views) << endl;
}
if (choice == 4)
{
cout << " What is the Artist's name? " << endl;
cin >> artist;
cout << " What song from the artist do you want to upload? " << endl;
cin >> song;
cout << " How many views does the song have? " << endl;
cin >> views;
cout << "Song Name: " << song << endl;
cout << "Artist's Name: " << artist << endl;
cout << "Streaming Service: " << "Spotify" << endl;
cout << "Money Made $ " << (Spotify * views);
}
if (choice == 5)
{
cout << " What is the Artist's name? " << endl;
cin >> artist;
cout << " What song from the artist do you want to upload? " << endl;
cin >> song;
cout << " How many views does the song have? " << endl;
cin >> views;
cout << "Song Name: " << song << endl;
cout << "Artist's Name: " << artist << endl;
cout << "Streaming Service: " << "Youtube" << endl;
cout << "Money Made $ " << (Youtube * views);
}
if (choice >= 6)
{
cout << " Error: Choice entered is not in the range of choices (1-5)" << endl;
}
return 0;
}
Here's a start to a flood of possible improvements and simplifications. Next step a switch, then on to arrays lists or vectors. Could even have a go-around to try again where wrong choices are made, or just to check another item.
// This program calculates how much a song makes on different streaming services
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
int main()
{
int choice{0};
int views{0};
string artist;
string song;
string streaming_service;
double rate{0};
// Choice= streaming selection/ num= the amount of views the song gets.
// This is where the menu is displayed
cout << "Which streaming service will you use to upload your song? " << endl;
cout << " 1: TIDAL " << endl;
cout << " 2: Amazon " << endl;
cout << " 3: Apple Music " << endl;
cout << " 4: Spotify " << endl;
cout << " 5: Youtube " << endl;
cout << " Please enter a number (1-5) to select which service you want to upload to. " << endl;
cin >> choice;
double Tidal= 0.0125, Amazon= 0.00402, AM= 0.00737, Spotify= 0.00437, Youtube= 0.00069;
if (choice == 1)
{
streaming_service = "TIDAL";
rate = Tidal;
}
if (choice == 2)
{
streaming_service = "Amazon";
rate = Amazon;
}
if (choice == 3)
{
streaming_service = "Apple Music";
rate = AM;
}
if (choice == 4)
{
streaming_service = "Spotify";
rate = Spotify;
}
if (choice == 5)
{
streaming_service = "Youtube";
rate = Youtube;
}
if (choice < 1 or choice >5)
{
cout << " Error: Choice entered is not in the range of choices (1-5)\n";
return -99;
}
cin.ignore(1000, '\n'); // MOST IMPORTANT
cout << " What is the Artist's name? ";
getline (cin, artist);
cout << " What song from the artist do you want to upload? ";
getline (cin, song);
cout << " How many views does the song have? ";
cin >> views;
cout
<< "\n------------------------------------\n"
<< " Song Name: " << song << '\n'
<< " Artist's Name: " << artist << '\n'
<< " No. of views: " << views << '\n'
<< " Rate $ " << rate << '\n'
<< "Streaming Service: " << streaming_service << '\n'
<< " Money Made $ " << rate * views << '\n'
<< "------------------------------------\n";
return 0;
}
Which streaming service will you use to upload your song?
1: TIDAL
2: Amazon
3: Apple Music
4: Spotify
5: Youtube
Please enter a number (1-5) to select which service you want to upload to.
2
What is the Artist's name? Alan Artist
What song from the artist do you want to upload? Alan's greatest hits
How many views does the song have? 34
------------------------------------
Song Name: Alan's greatest hits
Artist's Name: Alan Artist
No. of views: 34
Rate $ 0.00402
Streaming Service: Amazon
Money Made $ 0.13668
------------------------------------
Program ended with exit code: 0