C++ :: Promote User To Enter Y / N In Switch Statement To Continue Or Not

Nov 25, 2013

I need to promote user to enter y/n in switch statement to continue or not for an other conversion after showing results of each conversion.

#include <iostream>
using namespace std;
int main() {
char a;
double n, r1, r2;
cout<<"Please Chose the Temperature Unit to Convert: "<<endl<<endl;

[Code]....

View 1 Replies


ADVERTISEMENT

C :: Re-prompt User With Switch Statement Menu?

Sep 20, 2013

how to re-prompt a user with a switch statement menu that I prompted them earlier with. There are 4 options and after the user chooses an option the menu is supposed to pop up again unless the user chooses option 4, how do I do this? For reference I'll put up my source code.

Code:
int main(){
int init_bal,choice,balance,investment, donation;
printf("Welcome!

[Code]....

View 2 Replies View Related

C++ :: Program That Allows User To Enter Statement And Outputs Statistics?

Dec 12, 2013

a program that allows the user to enter a statement and outputs statistics; number of vowels, number of constants, percentage of vowels and constants, number of words, number of punctuation characters

View 2 Replies View Related

C++ :: Horizontal Scrolling ASCII Image - Hit Enter To Continue Or Esc To End

Sep 3, 2013

I would like the coded ASCII image to scroll horizontally 3 times and then end with the message:

"Hit Enter to continue or Esc to end"

If Enter is pressed, the program should then continue to scroll another 3 times and then display the same message above.

If Esc is hit then the program loop should stop similar to an escape sequence.

Here is my code that partially accomplishes my objective:

Code:
// Professor.cpp : The entry point for the console application.
#include <iostream>
#include <string>
#include <windows.h>
#include <stdlib.h>

[Code] .....

View 3 Replies View Related

C++ :: Continue Statement In Nested Loop

Feb 9, 2014

I was wondering how I could use a continue statement that continues in a nested loop. For example if I have

for (int i=0;i<amount;i++) {
for (int j=0;j<I[i];j++) {
for (int k=j+1;k<I[i];k++) {
if (P[i][j]+P[i][k]==C[i]) {
//What should be here?
}
}
}
}

If the condition is met then the most outer loop (in i) should continue to the next iteration.

If i simply fill in continue; in before the comment then it only continues the loop in k so that is not what I want.

View 5 Replies View Related

C++ :: Tell A Program To Continue Executing Next Line Of Code Within Nested IF Statement?

Nov 25, 2013

Is there a way to tell the program to continue reading the next line of code within a nested IF statement?

The reason I want to do this is because the two "else" statements in the following sample (the main and the nested else) will contain the same exact code and I don't want to repeat it twice. I know I can do this by creating a function and calling it from each else statement but I was just wondering if what I'm asking is even possible without using a function.

if(1 < 2) {
// yes 1 is less than 2
if(5 > 10) {
// do something
} else {
// no, 5 in not greater than 10
// here is where I want to tell the program to continue reading the next else statement

[Code] ....

View 8 Replies View Related

C++ :: Transfer If-else Statement Into Switch Statement?

Sep 7, 2013

How to make if else code below into SWITCH STATEMENT?

cout << "Enter the temperature: ";
cin >> temp;
cout << "Enter the pressure: ";
cin >> pressure;
cout <<endl;

[Code]....

View 6 Replies View Related

C++ :: Program That Accept Positive Integer - Use Do While To Allow User To Continue Or Not

Aug 10, 2014

So this is the activity (LOOPING) :

Write a program that accepts a positive integer. The program should be the same from the given output. Use do while to allow the user to continue or not.

OUTPUT must be:

n = 5
0
1==0
2==1==0
3==2==1==0
4==3==2==1==0
5==4==3==2==1==0

if n = 6
0
1==0
2==1==0
3==2==1==0
4==3==2==1==0
5==4==3==2==1==0
6==5==4==3==2==1==0

View 2 Replies View Related

C++ :: From If Else To Switch Statement

Mar 6, 2013

I was wondering how you would put this if else statement to a switch statement.

void PlayerDB::AddPlayer(const Player& avatarPlayer) {
char * playerName = new char[avatarPlayer.lenName()];
Player*player = NULL;

[Code] ....

View 1 Replies View Related

C++ :: Switch Statement Is Not Working?

Aug 16, 2014

okay so like case 2 and 3 is not working, also the program is still not finish but why isn't case 2 and 3 not functioning well on the switch part? case 1 works just fine

Code:
#include<stdio.h>
main ()
{
//passcode part (passcode is 1234)

[Code].....

View 5 Replies View Related

C :: Switch Statement Array

Apr 15, 2014

so I am trying to have an switch statement array. but every time i complete a case statement the whole process is returned. the thing is i want the menu to stay up even if i complete the case.

View 2 Replies View Related

C++ :: How To Link A Switch Statement To A If / Else

Aug 8, 2014

The sample output of this program would be:

Please select:
1 - Year
2 - Day
3 - Month
Input choice: 1
Input Number: 2
I'm a Sophomore!

Please select:
1 - Year
2 - Day
3 - Month
Input choice: 2
Input Number: 2
It's Tuesday.

Please select:
1 - Year
2 - Day
3 - Month
Input choice: 3
Input Number: 2
February. Heart's month!

Here is my code, I only typed the Year(levels) yet because when I tried to input 2(day) and 3(month) for the Input choice and after that, Inputting a number to 1-4 would yield the same result to case 1's year levels.

#include <stdio.h>
#include <conio.h>
using namespace std;

[Code].....

how to link the case 2 to days and case 3 to months?

View 1 Replies View Related

C++ :: How To Use Getline With Switch Statement

Sep 17, 2014

I have a problem with the switch statement because it doesn't prompt me to input something.

#include <iostream>
#include <fstream>
#include<cstring>
using namespace std;
//Compiler: Dev C++ and cygwin
void rd() {
string txt;

[Code] ....

I want to get rid of this kind of output ...

View 5 Replies View Related

C++ :: Converting If / Else To Switch Statement

Oct 8, 2014

if( vehicleUse == 'C' ) // Carpool
{
// TODO: Convert to a switch statement

if( vehicleLoad == 'E' ) // 6-8
cout << "Ford Windstar" << endl;
else if( vehicleLoad == 'F' ) // 8-10

[Code] .....

View 1 Replies View Related

C++ :: Compare Value In Switch Statement?

Sep 23, 2013

is it possible to compare value in switch statement? i.e: a > b

View 5 Replies View Related

C++ :: Switch Statement As A Menu?

Nov 1, 2013

I am using a switch statement as a menu. If I enter a non-integer value as my choice, I expect the error message , "Invalid entry", to display but instead the output keeps running.

View 2 Replies View Related

C/C++ :: Switch Statement Using Seekg

Mar 21, 2014

Right now I have to use seekg to read a letter from a text document then using a switch statement i have to show what that letter is

#include <iostream>
#include <fstream>
#include <math.h>
#include <time.h>

[Code]....

View 7 Replies View Related

C++ :: Switch Statement Falling Through All Cases

Jan 16, 2014

I was getting errors and I looked into the error and it told me to fix it by adding Code: { } in my case statements. I did, it compiled but fell through the whole thing. Lets say I enter 1, it outputs the was not found 5 times in a row.

Code:
void addressbook::EditNameOrDate() {
std::cout << "Enter 1 to Edit the contacts First Name: " << "
";
std::cout << "Enter 2 to Edit the contacts Last Name: " << "
";
std::cout << "Enter 3 to Edit the contacts Street Address: " << "

[Code] .....

View 8 Replies View Related

C :: Add Little Extra To Switch Statement Assignment

Jun 12, 2013

I pretty much got the assignment done. All it asked for was that you make a C program that displays which manufacturer owned a disk drive based on the code entered. Pretty simple. Just enter 1, 2, 3, or 4 and get the associated manufacturer. Though I am trying to implement an error messege to it for any interger that isn't 1-4.

Code: #include <stdio.h>
int main()
{

[Code]...

o errors are given and it works fine as long as you enter 1-4, but when you enter any other didgit it just stops the program without any messeges.

View 5 Replies View Related

C :: Switch Case Statement Does Not Execute

Feb 11, 2013

Im going through a C tutorial and im going to create a Database as part of the course. Im just in the very beginning of the project so its a very simple program so far.

Code:

#include<stdio.h>
main(){
/*Variabler for att lagra information om skiva*/
char title[200];
char artist[100];
int tracks;
int price;

[Code] ....

The first switch case statement takes me to the menu of choice, 1 or 2. However, chosing menu option one and trying to input a title or artist name, the program crashes.

Next, going into menu option 2 and then trying to print out, for example, title nothing happend. The process just ends.

Again, im sure this simple prototype is full of errors ....

View 1 Replies View Related

C++ ::  Switch Statement - Summing Items

Nov 6, 2014

I'm creating a program that is combining functions to show a menu to a user then the user picks numbered items which results in the totalling of a bill for them.

Where I'm stuck is after they're entered their selections, how to take them and sum them up. I've been trying with a switch statement, but I'm not sure if this is the right method. Is it even possible to sum separate cases of a switch statement together? Below is the code I've gotten so far:

#include <iostream>
#include <iomanip>
using namespace std;
void showMenu ();
void showBill (double, double, float, double);
void changeDue (double, int);

[Code] ....

View 3 Replies View Related

C++ :: Switch Statement Without Writing Each Case

May 28, 2014

I was just wondering if a switch statement can work without writing each case, for instance:

{ int age;
age=18;
while (age!=0) {
cout<<"Enter age :"<<endl;
cin>>age;
switch (age) {

[Code] ....

It works only for values specifically entered as a case, for instance if you enter 5 or 15 , it says bicycle, but if you enter anything inbetween it goes to default. Same with 18 and 100. It can't possibly be that you have to enter

case 19:
case 20:
case 21:
case 22:.......up to 100 to include all possible cases.

View 7 Replies View Related

C++ :: Passing A Function Value Into Switch Statement

Feb 23, 2015

I had it working with the switch statement within the function, but later instructions said that it must be inside of main. I just get a loop no matter what I do. 5 needs to exit the program, all the other selections need to display the corresponding cout statements. I've done something to where the inputs are not actually passing into the switch statement. If any value other than 1-5 is put in, the menu should repeat and prompt the user again.

#include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;
int call_menu(int selection);
double kilo_m(double miles);

[Code] .....

View 2 Replies View Related

C/C++ :: Algorithmic Complexity Of Switch Statement

Feb 14, 2014

Suppose you have a switch statement defined like:

switch (parameter) {
case ONE:
case TWO:
// ... other n-2 cases
case N:
doSomething();
break;
default:
somethingElse();
break;
}

What is the complexity of the doSomething()? Is it still equal to the complexity of doSomething() , or the complexity of doSomething() plus the number of case statements? In other words, does the number of case statements a conditional piece of code has count towards the complexity?

View 10 Replies View Related

C/C++ :: How To Make Switch Statement Work

Feb 26, 2014

The program i am trying to make is for practice of using switch. the idea is the user enters a number and the program will print a day of the week corresponding to said number.

the statement is not complete with all cases yet, but i dont want to write all of it until i am sure of it being correct.

errors when compiling (gcc) are as follows

1 warning and 3 errors generated.
Robins-MacBook-Air:array2 RDenton$ gcc array2.c
array2.c:26:9: warning: format string is not a string literal
(potentially insecure) [-Wformat-security]
printf(a[uservalue]);

[code]....

View 3 Replies View Related

C/C++ :: Switch Statement Not Working In Functions

Nov 22, 2014

The switch statement is giving me trouble. Worked fine in the main, but when I had to put it in separate functions per my professor, I had several issues. I guessing I am not calling the function correctly. Our group worked on it but could not find a solution to fix the switch statement.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <conio.h>
using namespace std;
//function prototypes
int menu(); //function to show main menu
void Seating_Chart(); //function to show seating chart

[Code] ....

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved