Hello everyone. I want this in C++ for my zylabs assignment. Iwrote this code: the days are working correctly but nights keepmixing up the output. Please let me know what I did wrong.Thanks
#include <iostream>
#include <string>
using namespace std;
int main() {
string time;
int day;
int night;
cin >> time >> day >> night;
if (time == "day" && day <= 3)
{
cout << "free" <<endl;
}
else if(time == "day" && day >= 4)
{
cout << "$8" <<endl;
};
if (time == "night" && night >=4)
{
cout << "$12" <<endl;
}
else if (time == "night" && night <=16)
{
cout << "$12" <<endl;
};
if (time == "night" && night >= 17&& night <= 54)
{
cout << "$15" <<endl;
};
if (time == "night" && night >= 55)
{
cout << "$13" <<endl;
};
if (time == "night" && night <= 4)
{
cout << "free" <<endl;
}
return 0;
}
zy Section 3.16- COMPSCI 1: Progra X + ← → с learn.zybooks.com/zybook/CHAFFEYCOMPSCI1 KocherSummer2022/chapter/3/section/16 My library > COMPSCI 1: Programming Concepts and Methodology I home > 3.16: LAB: Movie ticket prices = zyBooks night 50. 3.16 LAB: Movie ticket prices Write a program that takes in a string that holds the values "day" or "night" and an integer that holds a person's age, and outputs a movie ticket price. Movie prices are free for everyone under the age of 4. Daytime prices are $8 for everyone age 4 or higher. Nighttime prices are $12 for ages 4-16, $15 for ages 17-54 and $13 for ages 55 and above. Ex: If the input is: the output is: $15 Ex: If the input is: day 15 the output is: $8 EzyBooks catalog ▬▬▬▬ ▬▬ ? Help/FAQ 4x D O x 10:26 PM 7/9/2022 ⠀ Bilal Elali ▾
zy Section 3.16 - COMPSCI 1: Progra X + ← → с learn.zybooks.com/zybook/CHAFFEYCOMPSCI1 KocherSummer2022/chapter/3/section/16 My library > COMPSCI 1: Programming Concepts and Methodology I home > 3.16: LAB: Movie ticket prices = zyBooks $15 Ex: If the input is: day 15 the output is: $8 Ex: If the input is: night 3 the output is: free 397536.2649058.qx3zuy7 LAB ACTIVITY 3.16.1: LAB: Movie ticket prices ▬▬▬▬ main.cpp EzyBooks catalog ? Help/FAQ 7/10 Load default template. 4x D O Bilal Elali 10:26 PM 7/9/2022 x ⠀
Hello everyone. I want this in C++ for my zylabs assignment. I wrote this code: the days are working correctly but night
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am