#include <iostream> #include <iomanip> using namespace std; enum sizes{small, medium, large, jumbo}; sizes options(int drinkSize, int popcornSize); void printTotal(sizes price); int main() { int popcornSize, drinkSize; cout<<"Please pick the size of your popcorn: "<<endl; cout<<"1. Small"<<endl;cout<<"2. Medium"<<endl;cout<<"3. Large"<<endl;cout<<"4. Jumbo"<<endl; cin>>popcornSize; cout<<"Please pick the size of your Soda: "<<endl; cout<<"1. Small"<<endl;cout<<"2. Medium"<<endl;cout<<"3. Large"<<endl;cout<<"4. Jumbo"<<endl; cin>>drinkSize; printTotal(options(drinkSize, popcornSize)); return 0; } sizes options(int drinkSize, int popcornSize) { if (drinkSize==1 || popcornSize==1) { return medium; } else if (drinkSize==2 || popcornSize==2) { return small; } else if (drinkSize==3 || popcornSize==3) { return large; } else return jumbo; } void printTotal(sizes price) { int …

Member Avatar
Member Avatar
+0 forum 1

Part 2 of exploring/tasting the Swift language takes a look at dictionaries; process flow controls like loops, if/else and switch/case; functions and sorting. I hope I can follow this up with part 3, a closer look at class operations.

Member Avatar
Member Avatar
+2 forum 23

I, and many others, desired a "switch" keyword in Python. For me it was to a desire to make some of my code more compact and readable, as I often have many user selected options for the code to weed through. So I set off on a journey to figure out how to create a "switch" like statement. When I returned home, I was much enlightened and more thoroughly up to speed with Python. Great journey. What I settled on was a simple dictionary setup that returns strings that are then immediately evaluated/run with the "exec" keyword. Now "exec" can …

Member Avatar
Member Avatar
+0 forum 3

Hello Daniweb Community, I have recently been thinking about switching from a Wi-Fi connection to a direct connection over ethernet, however when I tried an ethernet connection from my router to my PS4, I calculated the average download speed after about 5 Wi-Fi connection tests and 5 ethernet connection tests and it averaged around the same. So there was no major difference, so what benefits would I have with a ethernet connection? I use my PS4 to listen to [Spotify](http://spotify.com) and sometimes it will drop or lag a bit, as well as when I have more than one person on …

Member Avatar
Member Avatar
+0 forum 14

This time just a simple example of grading scores (0 - 100) with letters (A - F). Two approaches are presented, one using switch/case in an "on the fly" function, and the other uses the score as an index to a string of letters F through A.

Member Avatar
Member Avatar
+1 forum 1

I have to create a program that asks a person to enter a 2 digit number (10-99) and convert it into words. I've been working on this for days and I still don't see what I'm doing wrong! PLEASE HELP ME!!! EXAMPLE: 27 twenty-seven [CODE]#include <iostream> using namespace std; int main() { int num; int ones_digit = num%10; int tens_digit = num/10; cout << "Enter a two-digit number:\n"; cin >> num; if (num>=20) && (num<100) { switch (tens_digit) { case 2: cout << " twenty- "; break; case 3: cout << " thirty- "; break; case 4: cout << " …

Member Avatar
Member Avatar
+0 forum 8

So far I have this but I need to use switch statements to make age< certain numbers for each age group. #include <iostream> #include <iomanip> #include <string> using namespace std; const float CHILDREN_MALE=50.00; const float CHILDREN_FEMALE=55.00; const float TEENAGERS_MALE=150.00; const float TEENAGERS_FEMALE=155.00; const float ADULTS_MALE=275.00; const float ADULTS_FEMALE=250.00; int main() { int Age, name; float Mcost=0.0; float total=0.0; char Gender; cout << fixed << showpoint << setprecision (2); //Display Menu cout << "-------------Fullerton Health Club--------------" << endl; cout << "Children (Age 1-12) " << endl; cout << setfill ('.'); cout << left << setw(15) << "\tMale" << right << setw(6) …

Member Avatar
Member Avatar
+0 forum 1

The total bill doesn't add up correctly, don't get where I went wrong? Total bill is way off. #include <iostream> #include<cmath> #include <iomanip> #include <string> using namespace std; const float Small = 1.20; const float Medium = 1.50; const float Large = 1.70; const float less_inches = 3.75; const float more_inches = 4.00; int main() { int No_Sand, Sand_size; float DrinkCost = 0.0, SandCost = 0.0, total = 0.0; float No_Drinks; char Drink_size; cout << fixed << showpoint << setprecision(2); //Display Menu cout << "------------Menu-------------" << endl; cout << "Drinks " << endl; cout << setfill('.'); cout << left << …

Member Avatar
Member Avatar
+0 forum 4

Not sure why it's not letting me choose the operation I want where I put "Enter an operation symbol..", I'm supposed to use switch statements to compute functions. #include <iostream> #include<cmath> #include <iomanip> #include <string> using namespace std; int main() { int type; int a, b, c, d; char op; cout << fixed << showpoint << setprecision(2); //select operation cout << "Enter a fraction: "; cin >> a; cin.ignore(); cin >> b; cout << "Enter another fraction: "; cin >> c; cin.ignore(); cin >> d; cout << "\tEnter an operation symbol (+,-, *, /): "; cin >> op; cin.ignore(); //operate …

Member Avatar
Member Avatar
+0 forum 6

Hi, I have a table in which I have Use ON and OFF status and I want to implement in laravell.What I have to do that it will work properly. Thanks!

Member Avatar
Member Avatar
+0 forum 1

I could think of half a dozen places this could start this conversation. I don’t believe the problem is hardware related, but the information that I am getting from my customer doesn’t convince me that it is vendor (AT&T DSL) related either. I maintain a small office with 5 computers which are connected to a switch. The switch goes to a router and the router goes to a DSL modem. The user has a database that lives on a server on the LAN. The user complains that “they are always getting kicked off the internet”. That being said, during my …

Member Avatar
Member Avatar
+0 forum 2

Here the switch() isn't working properly;not executing the function; & morever the while loop run twice when an invalid choice is given.. #include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> #define MAX 100 int vowel_count(char*); int conso_count(char*); void to_lower(char*); void to_upper(char*); void menu(); int main() { int cnt=0; char data[MAX]=" "; bool flag=false; printf("Enter String:\n"); gets_s(data); menu(); while(flag==false) { char ch; printf("\nEnter ur choice:\t"); scanf("%c",&ch); switch (toupper(ch)) { case 'A': cnt=vowel_count(data); printf("Vowels: %d",cnt); break; case 'B': cnt=conso_count(data); printf("Consonants: %d",cnt); break; case 'C': to_upper(data); break; case 'D': to_lower(data); break; case 'E': printf("\n%s\n",data); break; case 'F': printf("\nEnter new String:\n"); gets_s(data); break; case 'M': menu(); break; case …

Member Avatar
Member Avatar
+0 forum 5

I have a table that logs customer data but i want to search for the customer, upon finding that customer i want to click on the name and find it in another table that store other data. But here is where i am stuck i want to check which table the record is in and then display it. Is there anyway to do that. like using an IF statement or case. The criteria would be based on equipment type as the two other table stores data based on the type of equipment. Any help or reference would be good

Member Avatar
Member Avatar
+0 forum 2

Hello everybody! I'm trying to count the number of occurrences of each word in a text file. Problem situation requires to realize menu using "switch" statement (If file exist or not). There are following errors in my program ("case b" and "default" is not working): **[C++ Error] 03_int.cpp(61): E2126 Case bypasses initialization of a local variable [C++ Error] 03_int.cpp(72): E2238 Multiple declaration for 'w' [C++ Error] 03_int.cpp(50): E2344 Earlier declaration of 'w' [C++ Error] 03_int.cpp(83): E2126 Case bypasses initialization of a local variable** #include <fstream.h> #include <iostream.h> #include <map.h> #include <string> #include <cstdlib> #include <iomanip> #include <conio.h> typedef std::map<std::string, int> …

Member Avatar
Member Avatar
+0 forum 8

So decided I should switch to VS13 for the added benefits. Copied the cold, transfered the files, alls good right? Wrong. Actually its not that bad. Just one main problem. `ltm` See this fella? This is the one guy that is standing in the way of me and the debachury that i am programing. He is the name of my pointer for the time aspect of my program. so... `ltm->tm_mon;` He and his buddies are throughout my 500+ line program that functioned fine in Bloodshed. The problem? VS13 doesnt play friendly with localtime (they dated once and had a fall …

Member Avatar
Member Avatar
+0 forum 1

Hi,I am a beginner in php. And I am trying to create this php program where a user selects a picture and it displays it! Theare is an input page which is html and an processing page which is php! I seemes to have a problem in the processing page of the program.The problem is on line 22 in the processing page and it relates to escape character. How do I fix my issue please help I alredy spend more the several hours on it and still can't figure it out! Here are the code for the processing page: The …

Member Avatar
Member Avatar
+0 forum 1

GNS3 is a Graphical Network Simulator that allows emulation of complex networks. You may be familiar with VMWare, VirtualBox or Virtual PC that are used to emulate various operating systems in a virtual environment. These programs allow you to run operating systems such as Windows XP Professional or Ubuntu Linux in a virtual environment on your computer. GNS3 allows the same type of emulation using Cisco Internetwork Operating Systems. It allows you to run a Cisco IOS in a virtual environment on your computer. Dynamips is the core program that allows IOS emulation. GNS3 runs on top of Dynamips to …

Member Avatar
Member Avatar
+0 forum 2

Okay so I have an `inventory` class that accesses a static vector from my base class `MainShop`. I also have a `SwordShop` class which inherits from `MainShop`. (Both Inventory and SwordShop are derived classes). //SwordShop class void SwordShop::Shop { //I have a setter function where it takes an integer and a string and adds its to my hashmap. //Also have a getter function which has a for loop displaying my items in my map this->setWeaponSoldier(1, "1) Meito Ichimonji\n +4 Damage\n 150Gold"); this->setWeaponSoldier(2, "2) Shusui\n +10 Damage\n 230Gold"); this->setWeaponSoldier(3, "3) Elixir\n +16 Damage\n 300Gold"); this->setWeaponSoldier(4, "4) Blade of scars\n +24 Damage\n …

Member Avatar
Member Avatar
+0 forum 8

This program is supposed to run through the menus to eventually display the area or volume of a shape depending on the user's menu choices and input. However, it won't run the final menu and I'm not sure why. There aren't any problems when it goes through the debugger, it just doesn't run the whole program. I tried to change my last level switches to if statements but it didn't change anything. Any ideas? #include <iostream> using std::cout; using std::cin; int main() { int menuitem = 0, areamenuitem = 0, volumemenuitem = 0, base = 0, height = 0, radius …

Member Avatar
Member Avatar
+0 forum 3

I have attached one code of my project and i need a help in that. The code is running without any error but i am stuck up in modifying that how to make a statement, of invalid format of date or time if the user enters the wrong format should i use Try Catch blocks or simply use the if else statement I need to make it quite simple.

Member Avatar
Member Avatar
+0 forum 3

Nice to meet you, i am a newbie i would like to ask a question that bothers me out : 1).How to add the decimal representation of N! (5 <= N <= 1,000,000) is simply the multiplicity of the prime factor 5 in N! to my script? 2). I wanted to ask how the output of case#3:118 became case#3:27,whether the problem is string or an Integer? and how to solve it? Could you help me out. thanks here's my code code: Package test; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class test { String trailing; String y; /** * @param …

Member Avatar
Member Avatar
+0 forum 3

Are there any just 10 Mbps Switches? I'm doing a assignment for school and we need to use a 10 Mbps switch But i dont know any. If there are can I have the names.

Member Avatar
Member Avatar
+0 forum 3

Am having problems converting from if-else statements to switch statements and vice-versa

Member Avatar
Member Avatar
+0 forum 2

Write C++ a program that reads a person's age in years and print his/her age group. See the table below. Age Group name 1 year Childhood 2-3 years Infancy 4-5 years Preschool-Age 6–12 years School-Age 13–17 years Adolescence 18–29 years Young-Adulthood 30–39 years Thirties 40–64 years Middle-Age 56–48 years Aged >85 years Very-Old You have to using switch statement.

Member Avatar
Member Avatar
+0 forum 10

hi everyone i need your help, i ave a project where by i have to create a simple mortgage calculator. the problem is that i have to create a login frame where it will redirect me to the main frame which is the calculator.Could someone show me how to switch between the frames

Member Avatar
Member Avatar
+0 forum 4

I know I have a fundamental problem, I do not fully understand List objects. Based on a user input from a list box I want to creat a different list named `icons`. I previously had issues with the `switch` function, seemed I was doing it at the class level, so I am trying to put it in the following method. The error I get is `a local variable named "icons" is already defined in this scope.` I tried creating the list object outside the method, and I'm either not getting the syntax correct to assign within the switch or I …

Member Avatar
Member Avatar
+0 forum 11

Hi all, am trying to use bootstrap switch in my form. Am at a lost as to how to get the value of name="onoffswitch" from that field and insert it into mysql db, here is my code... div class="onoffswitch"> <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked> <label class="onoffswitch-label" for="myonoffswitch"> <div class="onoffswitch-inner"></div> <div class="onoffswitch-switch"></div> </label> </div>

Member Avatar
Member Avatar
+0 forum 6

Hello I have this code to detect the user browser, using if and else: [CODE]<?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) echo 'Internet explorer'; elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE) echo 'Mozilla Firefox'; elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE) echo 'Google Chrome'; else echo 'Something else'; ?>[/CODE] Is there a way to do this using the switch statement? I tried this, and it does not work, it just retuns default: [CODE]<?php switch(strpos($_SERVER['HTTP_USER_AGENT'], $browser) !== FALSE) { case $browser='MSIE': echo 'Internet explorer...'; case $browser='Firefox': echo 'Mozilla Firefox...'; case $browser='Chrome'; echo 'Google Chrome...'; default: echo 'Something else...'; } ?>[/CODE]

Member Avatar
Member Avatar
+0 forum 13

#include <cstdlib> #include <conio.h> #include <iostream> #include <stdlib.h> using namespace std; int main(int argc, char *argv[]) { int x,ctr; cout<< "Enter a day: "; cin>> x; for (ctr=x;x>0;x--) for (ctr=1;ctr<=12;ctr++) { switch (x) { case 1:cout<< "On the first day of Christmas\nMy true love sent to me...\n"; break; case 2:cout<< "On the second day of Christmas\nMy true love sent to me...\n"; break; case 3:cout<< "On the third day of Christmas\nMy true love sent to me...\n"; break; case 4:cout<< "On the fourth day of Christmas\nMy true love sent to me...\n"; break; case 5:cout<< "On the fifth day of Christmas\nMy true love …

Member Avatar
Member Avatar
+1 forum 5

**hi! i need help on fixing this program i made it seems that i can't let it run. Can someone give me some advice on what errors i have made and how i can fix it. thanks ** #include <iostream.h> #include <conio.h> void main () { int i; int j; for (i=1;i<=24;i++) for (j=1;j<=24;j++) { if (i%2==1) switch(i) { case 1: cout<<"On the first day of christmas\n my true love sent to me:"<<endl; break; case 3: cout<<"On the second day of christmas\n my true love sent to me:"<<endl; break; case 5: cout<<"On the third day of christmas\n my true love …

Member Avatar
Member Avatar
+0 forum 7

The End.