Hello everyone. I want this in C++ for my zylabs assignment. I wrote this code: the days are working correctly but night

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello everyone. I want this in C++ for my zylabs assignment. I wrote this code: the days are working correctly but night

Post by answerhappygod »

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;
}
Hello Everyone I Want This In C For My Zylabs Assignment I Wrote This Code The Days Are Working Correctly But Night 1
Hello Everyone I Want This In C For My Zylabs Assignment I Wrote This Code The Days Are Working Correctly But Night 1 (85.76 KiB) Viewed 65 times
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 ⠀
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply