KUNCI JAWABAN SOLOLEARN PIG LATIN, HOVERCRAFT, DLL
KUNCI JAWABAN SOLOLEARN EASY, MEDIUM, DLL BAHASA C++
1. SOLOLEARN PIG LATIN C++ (EASY)
QUESTION
You have two friends who are speaking Pig Latin to each other! Pig Latin is the same words in the same order except that you take the first letter of each word and put it on the end, then you add 'ay' to the end of that. ("road" = "oadray")
Task
Your task is to take a sentence in English and turn it into the same sentence in Pig Latin!
Input Format
A string of the sentence in English that you need to translate into Pig Latin. (no punctuation or capitalization)
Output Format
A string of the same sentence in Pig Latin.
Sample Input
"nevermind youve got them"
Sample Output
"evermindnay ouveyay otgay hemtay"
ANSWER
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string input;
getline(cin, input);
vector<string> col;
for(size_t i = 0, g = 0; i < input.length()+1; ++i)
{
if(input[i] == ' ' || i==input.length())
{
col.push_back(input.substr(g, i-g)); g = i+1;
}
}
for(auto& str : col)
{
cout << str.substr(1, str.length()-1) << str[0] << "ay ";
}
return 0;
}
2. SOLOLEARN ISOGRAM DETECTOR C++ (EASY)
QUESTION
An isogram is a word that has no repeating letters, whether they are consecutive or non-consecutive.
Your job is to find a way to detect if a word is an isogram.
Task: Write a program that takes in a string as input, detects if the string is an isogram and outputs true or false based on the result.
Input Format:
A string containing one word.
Output Format:
A string: true or false.
Sample Input:
turbulence
Sample Output:
False
ANSWER
#include <iostream>
#include <ctype.h>
using namespace std;
int main()
{
string input_string;
string output_string;
bool isogram_check = true;
cout << " " << endl;
cin >> input_string;
for (int i = 0; i < input_string.length(); i++)
{
output_string = output_string + char(toupper(input_string[i]));
}
for(int i = 0; i < output_string.length(); i++)
{
for(int o = i+1; o < output_string.length(); o++)
{
if(output_string[i] == output_string[o])
{
isogram_check = false;
break;
}
}
if(isogram_check == false)
{
break;
}
}
if (isogram_check == false)
{
cout << "false\n";
}
else
{
cout << "true\n";
}
}
3. SOLOLEARN HOVERCRAFT C++ (EASY)
QUESTION
You run a hovercraft factory. Your factory makes ten hovercrafts in a month. Given the number of customers you got that month, did you make a profit? It costs you 2,000,000 to build a hovercraft, and you are selling them for 3,000,000. You also pay 1,000,000 each month for insurance.
Task:
Determine whether or not you made a profit based on how many of the ten hovercrafts you were able to sell that month.
Input Format:
An integer that represents the sales that you made that month.
Output Format:
A string that says 'Profit', 'Loss', or 'Broke Even'.
Sample Input:
5
Sample Output:
Loss
ANSWER
#include <iostream>
using namespace std;
int main() {
int hovercraftSold, balance;
int cost = 21000000;
int price = 3000000;
cout << " \n";
cin >> hovercraftSold;
if(hovercraftSold*price > cost)
cout << "Profit";
else if(hovercraftSold*price == cost)
cout << "Broke Even";
else
cout << "Loss";
return 0; }
4. SOLOLEARN VOWEL COUNTER C++ (EASY)
QUESTION
You are in an English class, your teacher tells the class that vowels are the glue that hold words and sentences together.
They want to make sure you understand the importance of vowels in a sentence.
You are given example sentences and are to give a total amount of vowels that are in each sentence.
Task:
Write a program that takes in a string as input, counts and outputs the number of vowels (A, E, I, O, U).
Input Format:
A string (letters can be both uppercase or lower case).
Output Format:
A number which represents the total number of vowels in the string.
Sample Input:
this is a sentence
Sample Output:
6
ANSWER
#include <iostream>
using namespace std;
int main() {
char line[150];
int vowels;
vowels = 0;
cout << " \n";
cin.getline(line, 150);
for(int i = 0; line[i]!='\0'; ++i){
if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
line[i]=='o' || line[i]=='u' || line[i]=='A' ||
line[i]=='E' || line[i]=='I' || line[i]=='O' ||
line[i]=='U'){
++vowels; } }
cout << " \n" << vowels << endl;
return 0;}
5. SOLOLEARN GOTHAM CITY C++ (EASY)
QUESTION
You are a police officer, and you get a report of criminal activity! Should you go on your own, or should you call a superhero to help you fight the crime? If there are less than 5, you can handle this on your own, if there are 5-10, you will want to go with Batman for backup, and if there are more than 10, you should stay where it is safe and let Batman handle this on his own!
Task:
Determine whether you need to call backup based on the total number of criminals being reported.
Input Format:
An integer that represents the total number of criminals present at the scene.
Output Format:
A string that says 'I got this!', 'Help me Batman', or 'Good Luck out there!' depending on the scenario.
Sample Input:
7
Sample Output:
'Help me Batman
ANSWER
#include <iostream>
using namespace std;
string b="I got this!";
string c="Help me Batman";
string d="Good Luck out there!";
int a;
string Batman(int a){
if (a<5) return b;
else if ((a>=5)&&(a<=10)) return c;
else return d;}
int main(){
cin>>a;
cout<<Batman(a);
return 0;}
6. SOLOLEARN GUARD FLAMINGOS C++ (EASY)
QUESTION
You decide to add a pink flamingo lawn ornament every 2 feet around the perimeter of your yard. How many flamingos do you need to purchase?
Task:
Given the length and width of your rectangular yard, determine how many flamingos your should buy to put one every 2 feet along the edges of your yard.
Input Format:
Two integer values that represent the length and width of your front yard.
Output Format:
An integer that represents the total number of flamingos that you should purchase.
Sample Input:
10
10
Sample Output:
20
ANSWER
#include <iostream>
using namespace std;
int main() {
int length, width, result;
cin>>length;
cin>>width;
result = length+width;
cout << " " << result;
return 0;}
7. SOLOLEARN EXTRA-TERRESTRIALS C++ (EASY)
QUESTION
You meet a group of aliens, and their language is just like English except that they say every word backwards.
How will you learn to communicate with them?
Task:
Take a word in English that you would like to say, and turn it into language that these aliens will understand.
Input Format:
A string of a word in English.
Output Format:
A string of the reversed word that represents the original word translated into alien language.
Sample Input:
howdy
Sample Output:
ydwoh
ANSWER
#include <iostream>
#include <string.h>
using namespace std;
int main() {
char word[1000];
cin >> word;
for (int i = strlen(word)-1; i>=0; i--){
cout << word[i];}
return 0;}
8. SOLOLEARN NEVERLAND C++ (EASY)
QUESTION
If you live in Neverland, you never get any older! You and your twin go to Neverland for an afternoon, then your twin goes back home and you stay. Over time, how much older is your twin than you, and how old are they?
Task:
Evaluate the difference between your ages, and the age that your twin is now if you are given the age that you were when you got to Neverland, and the time that has elapsed since then.
Input Format:
Two integer values. The first represents your age when you arrived at Neverland, and the second, the number of years that have passed since your twin went back.
Output Format:
A string that states 'My twin is X years old and they are Y years older than me' Where X is their age and Y is the difference.
Sample Input:
10
8
Sample Output:
My twin is 18 years old and they are 8 years older than me
ANSWER
#include <iostream>
using namespace std;
int main() {
int urage, urtwinage, sum, diff;
cin >> urage;
cin>> urtwinage;
sum = urage + urtwinage;
diff = sum - urage;
cout << "My twin is " << sum << " years old and they are " << diff << " years older than me";
return 0;}
9. SOLOLEARN KALEIDOSCOPES C++ (EASY)
QUESTION
You sell souvenir kaleidoscopes at a gift shop, and if a customer buys more than one, they get a 10% discount on all of them!
Given the total number of kaleidoscopes that a customer buys, let them know what their total will be. Tax is 7%. All of your kaleidoscopes cost the same amount, 5.00.
Task:
Take the number of kaleidoscopes that a customer buys and output their total cost including tax and any discounts.
Input Format:
An integer value that represents the number of kaleidoscopes that a customer orders.
Output Format:
A number that represents the total purchase price to two decimal places.
Sample Input:
4
Sample Output:
19.26
ANSWER
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() {
int order;
cin >> order;
float total = order*5;
float totalAfter;
float discount = total*0.9;
if (order > 1){
totalAfter = discount + (discount*0.07);
printf("%.2f", ceil(totalAfter*100)/100);}
else{
totalAfter = total + (total * 0.07);
cout << ceil(totalAfter*100)/100;}
return 0;}
10. SOLOLEARN JUNGLE CAMPING C++ (EASY)
QUESTION
You are camping alone out in the jungle and you hear some animals in the dark nearby. Based on the noise they make, determine which animals they are.
Task:
You are given the noises made by different animals that you can hear in the dark, evaluate each noise to determine which animal it belongs to. Lions say 'Grr', Tigers say 'Rawr', Snakes say 'Ssss', and Birds say 'Chirp'.
Input Format:
A string that represent the noises that you hear with a space between them.
Output Format:
A string that includes each animal that you hear with a space after each one. (animals can repeat)
Sample Input:
Rawr Chirp Ssss
Sample Output:
Tiger Bird Snake
ANSWER
#include <iostream>
using namespace std;
int main(){
string reed;
string lions = "Grr";
string tigers = "Rawr";
string snakes = "Ssss";
string bird = "Chirp";
while (cin >> reed){
if (reed == lions)
cout << "Lion" << " ";
else if (reed == tigers)
cout << "Tiger" << " ";
else if (reed == snakes)
cout << "Snake"<<" ";
else if (reed == bird)
cout << "Bird" << " ";
else return 0; } }
11. SOLOLEARN NO NUMERALS C++ (MEDIUM)
QUESTION
You write a phrase and include a lot of number characters (0-9), but you decide that for numbers 10 and under you would rather write the word out instead. Can you go in and edit your phrase to write out the name of each number instead of using the numeral?
Task:
Take a phrase and replace any instances of an integer from 0-10 and replace it with the English word that corresponds to that integer.
Input Format:
A string of the phrase in its original form (lowercase).
Output Format:
A string of the updated phrase that has changed the numerals to words.
Sample Input:
i need 2 pumpkins and 3 apples
Sample Output:
i need two pumpkins and three apples
ANSWER
#include <iostream>
using namespace std;
int main() {
string s;
int i,k;
getline(cin,s);
for(i=0;s[i]!='\0';i++)
{here:k=i;
k++;
if(isdigit(s[i])){
if(isdigit(s[k])){
if(s[i]=='1'&&s[k]=='0'){
cout<<"ten";
i=i+2;
goto here;}
cout<<s[i]<<s[k];
i=i+2;
for(k=i;s[k]!='\0';k++) {
i++;
if(isdigit(s[k])) {
cout<<s[k];} }
goto here;}
switch(s[i]){
case '1':cout<<"one";
break;
case '2':cout<<"two";
break;
case '3':cout<<"three";
break;
case '4':cout<<"four";
break;
case '5':cout<<"five";
break;
case '6':cout<<"six";
break;
case '7':cout<<"seven";
break;
case '8':cout<<"eight";
break;
case '9':cout<<"nine";
break;
case '0':cout<<"zero";
break;
default:
break;} }
Else {
cout<<s[i]; } }
return 0;}
12. SOLOLEARN SUPERSALE C++ (MEDIUM)
QUESTION
Your favorite store is having a sale! You pay full price for the most expensive item that you get, but then you get 30% off of everything else in your purchase! How much are you going to save?
Sales tax is 7%.
Also, you leave anything below a dollar in your saving as a tip to the seller. If your saving is a round amount, you don't leave any tips.
Task:
Given the prices of items you want to purchase, determine how much you will save during your shopping!
Input Format:
An string of numbers separated by commas that represent the prices for all of the items that you want to purchase (without tax).
Output Format:
An integer number that represents the total savings that you got for shopping during the sale.
Sample Input:
100.25,80.99,40.00
Sample Output:
38
ANSWER
#include <iostream>
#include<vector>
#include<sstream>
#include<math.h>
using namespace std;
int main() {
string a;
cin>>a;
stringstream ss(a);
vector<double> v;
char c;
for(double x;ss>>x;){
v.push_back(x);
ss>>c;}
double res=0.0;
double max=v[0];
for(int i=0;i<(int)v.size();i++){
if(v[i]>max){
max=v[i]; } }
for(int i=0;i<(int)v.size();i++){
if(v[i]!=max){
res+=v[i]; } }
double d=0.3;
double e=1.07;
cout<<floor(res*d*e);
return 0;}
13. SOLOLEARN THE SPY LIFE C++ (MEDIUM)
QUESTION
You are a secret agent, and you receive an encrypted message that needs to be decoded. The code that is being used flips the message backwards and inserts non-alphabetic characters in the message to make it hard to decipher.
Task:
Create a program that will take the encoded message, flip it around, remove any characters that are not a letter or a space, and output the hidden message.
Input Format:
A string of characters that represent the encoded message.
Output Format:
A string of character that represent the intended secret message.
Sample Input:
d89%l++5r19o7W *o=l645le9H
Sample Output:
Hello World
ANSWER
#include <bits/stdc++.h>
using namespace std;
int main() {
char s[5000];
scanf(" %[^\n]",s);
int n = strlen(s);
reverse(s,s+n);
for(int i=0;i<n;i++){
if(s[i]==' ' || (s[i]>=65 && s[i]<=90) || (s[i]>=97 && s[i]<=122)){
printf("%c",s[i]);} }
printf("\n");
return 0;}
14. SOLOLEARN DEJAVU C++ (MEDIUM)
QUESTION
You aren't paying attention and you accidentally type a bunch of random letters on your keyboard. You want to know if you ever typed the same letter twice, or if they are all unique letters.
Task:
If you are given a string of random letters, your task is to evaluate whether any letter is repeated in the string or if you only hit unique keys while you typing.
Input Format:
A string of random letter characters (no numbers or other buttons were pressed).
Output Format:
A string that says 'Deja Vu' if any letter is repeated in the input string, or a string that says 'Unique' if there are no repeats.
Sample Input:
aaaaaaaghhhhjkll
Sample Output:
Deja Vu
ANSWER
#include <iostream>
using namespace std;
int main() {
string input;
getline(cin, input);
int input_length = input.length();
int i;
int j;
char a;
char b;
string z;
z="Unique";
for(i=0; i<input_length; i++) {
a=input[i];
for (j=i+1; j<input_length; j++) {
b=input[j];
if (a==b)
z="Deja Vu"; } }
cout<<z;
return 0;}
15. SOLOLEARN SAFETY DEPOSIT BOXES C++ (MEDIUM)
QUESTION
You are robbing a bank, but you’re not taking everything. You are looking for a specific item in the safety deposit boxes and you are going to drill into each one in order to find your item. Once you find your item you can make your escape, but how long will it take you to get to that item?
Task
Determine the amount of time it will take you to find the item you are looking for if it takes you 5 minutes to drill into each box.
Input Format
A string that represent the items in each box that will be drilled in order (items are separated by a comma), and secondly, a string of which item you are looking for.
Output Format
An integer of the amount of time it will take for you to find your item.
Sample Input
'gold,diamonds,documents,Declaration of Independence,keys'
'Declaration of Independence'
Sample Output
20
ANSWER
#include <stdio.h>
#include <string.h>
#define TIME 5
int main() {
char items [500];
char key [100];
int totalTime = 0;
int timeWork=0;
char *pToken = NULL;
fgets (items, 500, stdin);
fgets (key,100, stdin);
items[strlen(items)-1]=0;
pToken = strtok (items ,",");
while(pToken != NULL){
timeWork+=TIME;
if(strcmp(pToken, key) == 0 ) {
totalTime = timeWork;
break;}
pToken = strtok (NULL , ",");}
printf("%i", totalTime);
return 0;}
16. SOLOLEARN BALCONIES C++ (EASY)
QUESTION
You are trying to determine which of two apartments has a larger balcony. Both balconies are rectangles, and you have the length and width, but you need the area.
Task
Evaluate the area of two different balconies and determine which one is bigger.
Input Format
Your inputs are two strings where the measurements for height and width are separated by a comma. The first one represents apartment A, the second represents apartment B.
Output Format:
A string that says whether apartment A or apartment B has a larger balcony.
Sample Input
'5,5'
'2,10'
Sample Output
Apartment A
ANSWER
#include <iostream>
using namespace std;
int main() {
int height,weight,A;
int height1,weight1,B;
cin>>height; getchar();
cin>>weight; getchar();
cin>>height1; getchar();
cin>>weight1; getchar();
A=height*weight;
B=height1*weight1;
if (A>B) {
cout<<"Apartment A"; }
else {
cout<<"Apartment B";}
return 0; }
17. SOLOLEARN DUCT TAPE C++ (EASY)
QUESTION
You want to completely cover a flat door on both sides with duct tape. You need to know how many rolls of duct tape to buy when you go to the store.
Task:
Given the height and width of the door, determine how many rolls of duct tape you will need (a roll of duct tape is 60 feet long and 2 inches wide and there are 12 inches in each foot). Don't forget both sides of the door!
Input Format:
Two integers that represent the height and width of the door.
Output Format:
An integer that represents the total rolls of duct tape that you need to buy.
Sample Input:
7
4
Sample Output:
6
ANSWER
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
double height, widht, door, duc1, duc2, duck, math;
cin >> height;
cin >> widht ;
door=height*widht*2;
duc1=60/12;
duc2=2;
duck=duc1*duc2;
cout << ceil(door/duck);
return 0;}
18. SOLOLEARN IZZY THE IGUANA C++ (EASY)
QUESTION
Your pet Iguana has run away, and you found it up in a tree! It will come down right away if you brought the right snacks, but if you don't have enough, you will have to wait. You need 10 total snack points to bring it down. Lettuce is worth 5, Carrot is worth 4, Mango is worth 9, and Cheeseburger is worth 0.
Task:
Evaluate whether or not you have enough snack points to convince your iguana to come down.
Input Format:
Your input is a string that represents the snacks that you have. Snacks are separated by spaces, you can have any number of snacks, and they can repeat.
Output Format:
A string that says 'Come on Down!' if you have enough points, or 'Time to wait' if you do not.
Sample Input:
Mango Cheeseburger Carrot
Sample Output:
Come on Down!
ANSWER
#include <stdio.h>
#include <string.h>
int main () {
char str [2000];
int snack = 0;
scanf ("%[^\n]*c", str);
char *ptr = strtok(str, " ");
while (ptr != NULL) {
if (strcmp(ptr, "Lettuce")==0) {
snack += 5;}
else if (strcmp(ptr, "Carrot")==0) {
snack += 4;}
else if (strcmp(ptr, "Mango")==0) {
snack += 9;}
else if (strcmp(ptr, "Cheeseburger")==0){
snack += 0;}
ptr = strtok (NULL, " "); }
if (snack >= 10) {
printf ("Come on Down!");}
else {
printf ("Time to wait");}
return 0;}
19. SOLOLEARN LAND HO! C++ (EASY)
QUESTION
You are on a large ship and you put down anchor near a beautiful beach. There is a small boat ferrying passengers back and forth, and you get in line for it. How long will you have to wait to get to the beach? You know that 20 people can fit on the boat and each trip to shore takes 10 minutes each way.
Task:
Determine your wait time if you know the total number of people ahead of you in line.
Input Format:
An integer that represents the total number of people ahead of you in line.
Output Format:
An integer that represents the number of minutes that you will have to wait until you are standing on the beach.
Sample Input:
15
Sample Output:
10
ANSWER
#include <iostream>
using namespace std;
int main() {
int ahead;
cin>>ahead;
cout<<(10 + ahead / 20 * 20);
return 0;}
20. SOLOLEARN MULTIPLES C++ (EASY)
QUESTION
You need to calculate the sum of all the multiples of 3 or 5 below a given number.
Task:
Given an integer number, output the sum of all the multiples of 3 and 5 below that number.
If a number is a multiple of both, 3 and 5, it should appear in the sum only once.
Input Format:
An integer.
Output Format:
An integer, representing the sum of all the multiples of 3 and 5 below the given input.
Sample Input:
10
Sample Output:
23
ANSWER
#include <iostream>
using namespace std;
int main() {
int sum = 0;
int x = 1;
int y;
cin >> y;
while(x<y){
if((x % 5 == 0) || (x %3 == 0)) {
sum += x; }
x ++;}
cout<<sum<<endl;
return 0;}
21. SOLOLEARN YOUTUBE LINK FINDER C++ (MEDIUM)
QUESTION
You and your friends like to share YouTube links all throughout the day. You want to keep track of all the videos you watch in your own personal notepad, but you find that keeping the entire link is unnecessary.
Keep the video ID (the combination of letters and numbers at the end of the link) in your notepad to slim down the URL.
Task:
Create a program that parses through a link, extracts and outputs the YouTube video ID.
Input Format:
A string containing the URL to a YouTube video. The format of the string can be in "https://www.youtube.com/watch?v=kbxkq_w51PM" or the shortened "https://youtu.be/KMBBjzp5hdc" format.
Output Format:
A string containing the extracted YouTube video id.
Sample Input:
https://www.youtube.com/watch?v=RRW2aUSw5vU
Sample Output:
RRW2aUSw5vU
ANSWER
#include<bits/stdc++.h>
using namespace std;
int last(string s,char ch){
for(int i=s.size()-1;i>=0;i--){
if(s[i]==ch)
return i;}
return -1;}
int main(){
string s;
getline(cin,s);
if(s.find("=")==-1){
int p=last(s,'/');
cout<<s.substr(p+1);}
else
cout<<s.substr(s.find("=")+1);}
22. SOLOLEARN POPSICLES C++ (EASY)
QUESTION
You have a box of popsicles and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later.
Task
Given the number of siblings that you are giving popsicles to, determine if you can give them each an even amount or if you shouldn't mention the popsicles at all.
Input Format
Two integer values, the first one represents the number of siblings, and the second one represents the number of popsicles that you have left in the box.
Output Format
A string that says 'give away' if you are giving them away, or 'eat them yourself' if you will be eating them yourself.
Sample Input
3 9
Sample Output
give away
ANSWER
#include <iostream>
using namespace std;
int main() {
int siblings, popsicles;
cin >> siblings;
cin >> popsicles;
if(popsicles%siblings==0){
cout << "give away";
}
else{
cout << "eat them yourself";
}
return 0;
}
23. SOLOLEARN HALLOWEN CANDY C++ (EASY)
QUESTION
You go trick or treating with a friend and all but three of the houses that you visit are giving out candy. One house that you visit is giving out toothbrushes and two houses are giving out dollar bills.
Task
Given the input of the total number of houses that you visited, what is the percentage chance that one random item pulled from your bag is a dollar bill?
Input Format
An integer (>=3) representing the total number of houses that you visited.
Output Format
A percentage value rounded up to the nearest whole number.
Sample Input
4
Sample Output
50
ANSWER
#include <iostream>
using namespace std;
int main() {
float houses,dollar;
cin>>houses;
{
dollar = (((houses-(houses-2)))/houses) * 100;
if (dollar == (int)dollar){
cout << dollar;
}
else
cout << (int)dollar+1;
}
return 0;
}
24. SOLOLEARN FRUIT BOWL C++ (EASY)
QUESTION
You have a bowl on your counter with an even number of pieces of fruit in it. Half of them are bananas, and the other half are apples. You need 3 apples to make a pie.
Task
Your task is to evaluate the total number of pies that you can make with the apples that are in your bowl given to total amount of fruit in the bowl.
Input Format
An integer that represents the total amount of fruit in the bowl.
Output Format
An integer representing the total number of whole apple pies that you can make.
Sample Input
26
Sample Output
4
ANSWER
#include <iostream>
using namespace std;
int main() {
int fruit, result;
cin>>fruit;
result = fruit/6;
cout << " " << result;
return 0;
}
25. SOLOLEARN BALLPARK ORDERS C++ (EASY)
QUESTION
You and three friends go to a baseball game and you offer to go to the concession stand for everyone. They each order one thing, and you do as well. Nachos and Pizza both cost $6.00. A Cheeseburger meal costs $10. Water is $4.00 and Coke is $5.00. Tax is 7%.
Task
Determine the total cost of ordering four items from the concession stand. If one of your friend’s orders something that isn't on the menu, you will order a Coke for them instead.
Input Format
You are given a string of the four items that you've been asked to order that are separated by spaces.
Output Format
You will output a number of the total cost of the food and drinks.
Sample Input
'Pizza Cheeseburger Water Popcorn'
Sample Output
26.75
ANSWER
#include <iostream>
using namespace std;
int main() {
unsigned short bill;
string words;
for(int roll=0;roll<4;roll++){
cin >> words;
int braker = 0;
if(words == "Water"){
bill+=4;
braker = 1;
}
if(words == "Nachos"||words == "Pizza"){
bill+=6;
braker = 1;
}
if(words == "Cheeseburger"){
bill+=10;
braker = 1;
}
if(braker == 0){
bill+=5;
}
}
cout << bill+bill*0.07 << endl;
return 0;
}
26. SOLOLEARN CHEER CREATOR C++ (EASY)
QUESTION
You are cheering on your favorite team. After each play, if your team got over 10 yards further down the field, you stand up and give your friend a high five. If they don't move forward by at least a yard you stay quiet and say 'shh', and if they move forward 10 yards or less, you say 'Ra!' for every yard that they moved forward in that play.
Task
Given the number of yards that your team moved forward, output either 'High Five' (for over 10), 'shh' (for <1), or a string that has a 'Ra!' for every yard that they gained.
Input Format
An integer value that represents the number of yards gained or lost by your team.
Output Format
A string of the appropriate cheer.
Sample Input
3
Sample Output
Ra!Ra!Ra!
ANSWER
#include <iostream>
using namespace std;
int main() {
int yards;
cin>>yards;
if(yards<1){
cout<<("shh");
}else if(yards>10){
cout<<("High Five");
}else{
for(int x=0;x<yards;x++){
cout<<("Ra!");
}
}
return 0;
}
27. SOLOLEARN SKEE-BALL C++ (EASY)
QUESTION
You are playing a game at your local arcade, and you receive 1 ticket from the machine for every 12 points that you score. You want to purchase a squirt gun with your tickets. Given your score, and the price of the squirt gun (in tickets) are you able to buy it?
Task
Evaluate whether or not you have scored high enough to earn enough tickets to purchase the squirt gun at the arcade.
Input Format
The first input is an integer value that represents the points that you scored playing, and the second input is an integer value that represents the cost of the squirt gun (in tickets).
Output Format
A string that say 'Buy it!' if you will have enough tickets, or a string that says 'Try again' if you will not.
Sample Input
500
40
Sample Output
Buy it!
ANSWER
#include <iostream>
using namespace std;
int main() {
int points;
int SquirtGun;
cin >> points;
cin >> SquirtGun;
//if (SquirtGun<points){//>>>logic not correct
if ( SquirtGun <= (points /12)){
cout << "Buy it!" ;
//else (SquirtGun>points);//>>>else clause can not have a condition
}else{
cout << "Try again" ;
}
return 0;
}
28. SOLOLEARN PAINT COST C++ (EASY)
QUESTION
You are getting ready to paint a piece of art. The canvas and brushes that you want to use will cost 40.00. Each color of paint that you buy is an additional 5.00. Determine how much money you will need based on the number of colors that you want to buy if tax at this store is 10%.
Task
Given the total number of colors of paint that you need, calculate and output the total cost of your project rounded up to the nearest whole number.
Input Format
An integer that represents the number of colors that you want to purchase for your project.
Output Format
A number that represents the cost of your purchase rounded up to the nearest whole number.
Sample Input
10
Sample Output
99
ANSWER
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float x;
float cost;
float colors;
cin >> colors;
x = 40.00 + (5.00*colors);
cost = x + (x/10);
cout << (int)ceil(cost);
return 0;
}
29. SOLOLEARN ARGENTINA C++ (EASY)
QUESTION
You are in a hat store in Argentina! The prices are listed in US Dollars and Argentinian Pesos. You have both, but you want to make sure you pay the lower price! Do you pay in Dollars or Pesos? The exchange rate is 2 cents for every Peso.
Task
Create a program that takes two prices and tells you which one is lower after conversion.
Input Format
Two integer values, the first one is the price in Pesos and the second one is the price in Dollars.
Output Format
A string that says which currency you should make the purchase in ('Dollars' or 'Pesos').
Sample Input
4000
100
Sample Output
Pesos
ANSWER
#include<iostream>
using namespace std;
int main() {
int Pesos, Dollars;
cin>>Pesos>>Dollars;
int c = Pesos*0.02;
if(c<=Dollars){
cout<<"Pesos"<<endl;
}else{
cout<<"Dollars";
}
return 0;
}
30. SOLOLEARN CANDLES C++ (EASY)
QUESTION
It is almost Hanukkah and the store in your town is completely out of candles! You decide to place an order online, and you talk to your friends to see who else needs candles. How many candles should you order in total for the holiday?
Task
Determine how many candles you need to order based on how many friends ask to join your order (each friend will need 9 candles).
Input Format
An integer that represents the number of friends that ask to order candles with you.
Output Format
An integer that represents the total number of candles that you need to order.
Sample Input
4
Sample Output
45
ANSWER
#include <iostream>
using namespace std;
int main() {
int candles, result;
cin >> candles;
result = (candles+1)*9;
cout << " " << result;
return 0;
}
31. SOLOLEARN EASTER EGG
QUESTION
You go hunting for Easter eggs with a friend. You think that you have found all of the eggs, but you want to make sure that you don't leave any behind! Compare Easter baskets with your friend to decide if you should keep hunting.
Task:
If you know the total number of eggs that were hidden and the amount in both of your baskets. Evaluate whether it is time to eat candy or keep hunting for more eggs.
Input Format:
Three integer values. The first represents the total number of eggs, the second, the amount in your basket, and lastly the amount that your friend has found.
Output Format:
A string that says 'Keep Hunting' if there are still eggs out there or 'Candy Time' if you found all the eggs.
Sample Input:
100
40
60
Sample Output:
Candy Time
ANSWER
#include <iostream>
using namespace std;
int main() {
int eggs, mine, others;
cin >> eggs;
cin >> mine;
cin >> others;
if ( eggs == mine+others){
cout << "Candy Time" ;
}else{
cout << "Keep Hunting" ;
}
return 0;
}
JIKA ADA EROR PADA KUNCI JAWABAN YANG TELAH SAYA BERIKAN ATAU ADA YANG INGIN DITANYAKAN BOLEH TULIS KOMENTAR DI BAWAH YAA, TERIMA KASIH. SEMOGA BERMANFAAT!!
Komentar
Posting Komentar