C/C++ :: Loop Until Alphabet Is Entered?

Dec 4, 2014

im working on our project and this part of the project which says to add a new a room.

Details:

Open the file (ROOMS) that maintains all the ROOMS records.

Ask the user to enter the required data Room_Type and Room_Rate, then save it.

Keep asking the user (Do you want to continue?) until the user enters (N OR n), this should stop the data entry and get the user back to the main menu.

Myproblem :: i keep getting error at the bottom says my while statement is wrong " IntelliSense: no operator "!=" matches these operands"

My other problem:: how do i get back to the main menu?

so what ive done till now is.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
int choice,i=1,Room_rate;
string alphabet;
string Room_type;

[code].....

View 3 Replies


ADVERTISEMENT

C++ :: Infinite Loop After Char Is Entered?

Nov 17, 2013

I have the program working but when I check if the input to make sure it is not a char it creates a infinite loop. I used an if statement to check for the issue and solve it but its not working. I even tried throwing an exception but I learned later they are not used for things like this.

Code:
#include <iostream>
#include <limits>
#include "contacts.h"
using namespace std;
int main()

[Code].....

View 10 Replies View Related

C/C++ :: Break Out Of Loop When A Certain Word Or Phrase Is Entered

Dec 24, 2014

The code below replaces lowercase characters by upper case and uppercase character by lowercase. Also, I should be able to break out of the loop when I enter 'exit'. It does what it is supposed to do. But I had to come up with a function to break out of 'the while loop'. Is there any shorter or more concise way to break out of the loop when 'exit' is entered?

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

[Code]......

View 5 Replies View Related

C/C++ :: Infinite Loop If Non-numerical Character Entered

Jul 28, 2014

it will produce the answer above..when user enter a nonnumerical character it will force the user to reenter again

do {
cout<<"Min of the secret number : ";
cin>>min;
}while(cin>>min);
cout<<"Max of the secret number : ";
cin>>max;

this is my coding but it will auto jump out when i enter non-numeric character

View 7 Replies View Related

C/C++ :: Do While Loop That Terminates Program When 99999 Is Entered?

Oct 21, 2014

I am trying to do a while loop that terminates the program when 99999 is entered but otherwise allows infinite integers to be entered. My problem is that when a negative number is entered it crashes and also when I enter a number it displays it twice.

#include <stdio.h>
#include <stdlib.h>
main() {
int number;
printf("Input an integer.
"); do {
scanf("%d",&number); /* read a single integer value in */
printf("%d
",number);
} while (number != 99999);
}

View 14 Replies View Related

C/C++ :: Loop That Outputs Until Quit Is Entered For Customer Name

Apr 15, 2015

I was asked to create a loop that outputs until Quit is entered for customer name. This is what my output is suppose to look like: I will also attach the code I made. Im sure there is something wrong with my while command. But I believe there is something else I have to add to print out the last customer name: quit output.

Lab 28 - Your Name

Input Customer Name: xxxxxxxxxx
Input Customer State: xx
Input Product Price: xxx.xx

Customer Name: xxxxxxxxxxx
Customer State: xx
Product Price: xxx.xx
Product Discount: xxx.xx
Discounted Price: xxx.xx
Sales Tax: xx.xx
Total Cost: xxx.xx

Input Customer Name: Quit

End of Lab 28 for Your Name

Code :

#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
double pPrice , pDiscount , dPrice , sTax , tCost ;
int cName , cState ;

[Code] .....

View 4 Replies View Related

C/C++ :: Finding Sum Of Values Entered By User In While-loop?

Aug 26, 2014

Keep track of the sum of values entered (as well as the smallest and the largest) and the number of values entered. When the loop ends, print the smallest, the largest, the number of values,and the sum of values. Note that to keep the sum, you have to decide on a unit to use for that sum; use cm.

View 9 Replies View Related

C :: How To Make A Switch Case Loop After Input Entered

Dec 31, 2013

I'm working on a code that needs to loop a switch case back to the beginning after a certain input is entered.

ex) Code:

printf("Select an option);
printf("1. Play game");
printf("2. Status");
printf("3. Exit");
scanf("%i", &userinput);
switch(userinput);

[Code]...

For my program, I want option 2 to display something, then loop back to "select and option" after the user presses enter. How would I write that? Would i use a while? do while?

View 3 Replies View Related

Visual C++ :: Using Loop To Take User Input And Keep Running Sum Until 0 Entered

Feb 28, 2013

I am stuck on an exercise where i am supposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:

#include <iostream>
int main() {
using namespace std;
int num;
int total = 0;
int x;

[Code] ....

The full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++?

View 4 Replies View Related

C/C++ :: Wrapping Alphabet Using ASCII

Jan 26, 2011

I'm currently working on a project that utilitzes a Caesar Cipher. Basically, it reads input from a file and then, depending upon the input file, requires encrypting or decrypting. The cipher used to encrypt/decrypt simply adds/subtracts an integer from each character in the input file. All input is lowercase alphabetic characters (ASCII 97-122). My problem is trying to figure out how to wrap the ciphered characters, e.g., if the cipher require a shift of +5 and the character read was 'x', a shift of +5 to the right would produce 'c' (beginning with 'x' and counting up 5 letters: 'y', 'z', 'a', 'b', 'c').

I've written some crude and cumbersome loops that will work, but there has to be a better way. It is my understanding that it can be done using the modulus operation, %, but I cannot figure out how. I spent several hours trying to figure out the modulus approach, but no luck.

View 6 Replies View Related

C :: Make Alphabet Soup On Programming

Mar 19, 2014

I'm trying to make an alphabet soup on C programming, and I'm stuck with a problem.I need to make a function able to automatically find all the words that exist in alphabet soup.

View 4 Replies View Related

C++ :: How To Count Letters Of Alphabet In A String

May 5, 2014

I am creating a program where I count all the letters of the alphabet from a user submitted string.

How would I go about this?

I am completely new, so simplicity is best. I am suppose to use arrays.

View 4 Replies View Related

C/C++ :: How To Declare Alphabet Type Of Data

Feb 15, 2014

I know how to store numeric data using keywords int, long, float, and so on. I'm making my own program called "Who is your soul-mate".The only question I want to ask is what's the keyword for storing alphabet data? As you can see below on my source file. I want to replace "int" keyword with another keyword that can store alphabet data. It's all in standard C.

#include <stdio.h>
int soulm01, soulm02, soulm03;
int year_of_birth;
int main(void)

[Code].....

View 5 Replies View Related

C :: For Every Char Of Given Alphabet - Count How Many Times In The String

Feb 1, 2013

Be given a string of chars, where each single char belongs to the following alphabet: a..zA..Z0..9 (So, in the string there are only lowercases, uppercases and digits. No blank, no comma, ...).

For every char of the given alphabet, count how many times in the string

1----- the char is preceded by its predecessor in the alphabet (consider that the predecessor of 'a' is '9')
2----- the char is followed by its successor in the alphabet (consider that the successor of '9' is 'a')
3----- the char belong to a sequence of identical chars whose length is at least three (i.e.: in the string cc74uyrpfccc348fhsjcccc3848djccccc484jd for three times the character 'c' satisfies this condition)
4----- what is the longest substring of characters strictly rising (the following is greater (>) of the previous)
5----- what is the longest substring of successive characters (i.e.: fhkjshdfruytyzABCDEfglsj => 7)
6----- the frequencies of any char (if in the string the character 'g' occurs 12 times, its frequency is 12)

View 5 Replies View Related

C/C++ :: Find Max Number Entered By User And Terminate When Negative Number Entered

Jul 15, 2014

I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.

#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;

[Code] ....

View 9 Replies View Related

C :: Function To Check Whether Input Is Composed ONLY Of Alphabet / Space

Feb 15, 2013

This code is supposed to ask the user to input characters at most 20 and they should only be composed of alphabets/spaces..

Code:
#include <string.h>
#include <stdio.h>
#include <ctype.h>

int main(){
char addressbook[6][30][0];
int current_record = 0, length, i=0;

[Code] ....

I have removed the error from the main code but there's still this lingering error in the return part.

syntax error before 'return'.

It won't compile.

View 5 Replies View Related

C++ ::  keyboard That Counts Frequency Of Occurrence Of All Letters Of Alphabet

Mar 24, 2013

c++ program which reads an input stream from the keyboard that counts the frequency of occurrence of all the letters of the alphabet

View 5 Replies View Related

C++ :: Extract And Check First Character Of String Array Is Alphabet

Oct 3, 2013

How i could go about extracting and checking if the very first character in my string array is an alphabet

View 2 Replies View Related

C++ :: Sum Of Digits Entered And Output

Feb 25, 2014

A problem that lets the user enter any positive integer, but you do not have to check for this, and then calculates the sum of the digits and displays this to user. For example, if user enters 14503, the outputted sum of the digits would be 13. You need turn in an algorithm, C++ source code and output.

how do i even go about making 1 add to 4? and so on. I'm lost.

View 5 Replies View Related

C++ :: How Many Entries Entered By The User

Sep 16, 2014

when i declare local variable x and use it in array,the error is occure that use of un assign local variable.

namespace ConsoleApplication11
{class Program
{
static void Main(string[] args)
{
int x;
Console.Write("enter how many entries you want");

[Code]...

View 2 Replies View Related

C# :: Compare One Value To A Previously Entered Value?

Oct 3, 2014

I am currently taking a C# class. Our current assignment has us entering a player name, and number of hits and displaying these in one set of labels. I have coded everything for the primary function of this program and it works. However, I also have to have a second set of labels that show the highest number of hits entered (if I enter 44, the first and second labels change to 44; if I then enter 27, the first label changes to 27 and the second stays at 44; and if i enter 55, the first label changes to 55 and the second label changes to 55) and the corresponding player name. I have tried searching and reading and I can't seem to figure out how this is done.

View 5 Replies View Related

C :: Checking What User Has Entered (City)

Mar 9, 2013

I am using Dev C++ on a windows computer.

In my code, the user enters the name of a city, and then according to what city it is, the program displays the coordinates of that city

I can't find a way of figuring out and checking which city the user has entered so the code can displays its appropriate latitude and longitude.

View 9 Replies View Related

C :: How To Output The Last Positive Number Entered

Jan 25, 2014

Create a program that keeps on reading positive numbers until user enters a zero value, and then outputs the last positive number entered.

I do not know how to output the 'last positive number' and I do not even know am I doing things correctly so far....

Code:
#include <stdio.h>
int main() {
double num;
for(;;) {
printf("Enter a positive number: ");
scanf("%lf",&num);

[Code] ....

View 9 Replies View Related

C++ :: Get Entered Number Become Fragmented And Then Resembled

Nov 22, 2013

I have to make a program and how to go with it. What is excepted of me is to have a entered number, become fragmented, and then resembled.

Ex. 1394--> 1 3 9 4 --> 1394

View 6 Replies View Related

C++ :: How To Use A User Entered File In Fstream

Feb 14, 2014

So, I am making a name-database-type-thing and I want the user to be able to enter there own file. Like, here:

string fileName;
string name;
cout<<"What is your file name?"<<endl;
getline(cin, fileName);
ifstream nameFile(fileName);
getline(cin, name);
nameFile<<"Name: "<<endl;

Well, that last part is in a loop, so you can enter an unlimited number of names to the .txt file.

So, it won't let me use the string in ifstream. How can I fix this? This maybe unclear, so if it is just say so and I will edit it.

View 6 Replies View Related

C++ :: How To Collect Input That Has Been Entered By User

Mar 19, 2013

I am making a program that will suggest meal options when choosing specifics contained within, e.g. style, base, main, sauce.

What I would like to know is how to collect the input that has been entered by the user, say you are given 4 lists and each has an option, how could I chain these together in order to cout a suggestion that is in my database?

-------------------------------------------------------------------------------
Example (not my real Q's and A's):

OUTPUT: What meat would you like?
INPUT: "Beef" //<collect this!
OUTPUT: What sauce would you like?
INPUT: "Tomato" //<and this!
OUTPUT: What would you like to have as the main/base?
INPUT: "Pasta" //<and this!
OUTPUT: I can suggest... "Spaghetti Bolognese" //< and return this from the database using the 3 filters
--------------------------------------------------------------------------------

View 1 Replies View Related







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