C :: How To Get Upper Case And Lower Case Equal

Feb 18, 2015

I just dont know how to get my upper case and lower case equal...heres the program: Write a program to calculate utility cost for ACME UTILITY COMPANY. The company has 3 types of customers (R) residential, (C) Commercial and (G) government. Customers are billed based on the number of kilowatts used and they type of customer they are (R,C,or G).

Residential cusstomers are charged 0.25 cents per kilowatt hour for the first 500kw used, and 0.35 cent per kwh for all kw used over 500.Commercial customers are charged 0.22 cents per kilowatt hour for the first 999kw used, 0.29 cents per kwh for all kw used over 999 kw up to 1999 and 0.45 cents per kwh for all kilowatts used greater than 1999. Commercial customers that use over 2000 kw are charged a special surcharge of 100.0 in addition to the regular charges.

Government customers are charged 0.34 cents for the first 1500 kwh used(<=1500). 0.30 cent for the next 1000 kwh(1501-2500) and 0.25 cents for all kwh used over (>=2501)

in addition residential customer are charged .5% tax on the cost utilities while Commercial customers are 5% tax on the cost of utilities not including the special surcharge Government customers are not charged a tax

Code:

#include <stdio.h>
#include <math.h>
int main(void)
{
int R;
int ct;
int kwh;
int taxes;
int surcharge;
int charge
}

[code].....

the program should quit with Q and calculate the amount owed, utility charge, and surcharge

View 8 Replies


ADVERTISEMENT

C :: Way To Check If Letter Is Upper Or Lower Case

Jul 7, 2014

can i do in this way to check if letter is upper case or lower case is it better to using casting or i can do without casting.

Code:

if(selectOption == (char)81){
selectOption = (char)113;
}

View 2 Replies View Related

C :: Converting Two Strings To Upper And Lower Case Using Function

Dec 6, 2014

My code so far

Code:

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

[Code]....

I keep getting these 3 errors :

error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '{' at end of input|.

View 4 Replies View Related

C++ :: Enter Name Of Your Favorite City In Lower Case

Oct 1, 2013

Please enter the name of your favorite city in lower case: (user for example enters) chicago

chicago is supposed to be data entered by the user.

My question is what code should i enter to enable the user to enter such data and how can i use that data (chicago) with the rest of my code.

View 6 Replies View Related

C++ :: Change First Letter Of Each Name To Upper Case?

Oct 2, 2013

I can get the first letter to change if there is only one word. But if there are two words it wont change and display the second word's first letter and I'm not sure why.

#include <iostream>
#include <iomanip>
#include <cstring>

[Code].....

View 3 Replies View Related

C++ :: Function To Change Char Array String To Lower Case

Feb 17, 2014

This code ran well until i added in the ToLower function which is supposed to convert the char array string to lower case (based off ascii strategy -32). correct this function so it converts string to lower case and doesn't get errors.

#include <iostream>
#include <string>
using namespace std;
const int MAX = 81; //max char is sting is 80
void ToLower(char s[]);
int main(){
string y_n;

[Code]...

View 1 Replies View Related

C/C++ :: Upper Case Conversion And Digit Summing

Feb 23, 2015

Write a program that reads characters from the keyboard using the getch() function. All lower case letters will be converted to upper case and printed out to the display using the putchar() function. All uppercase letters will be printed using putchar(). All individual digits will be accumulated and the sum will be printed at the end of the program using printf(). You will write a function to return the upper case of the letter and a second function which receives the current sum and the character digit.

The convert digit function will convert the character digit to a decimal value and accumulate the digit to the sum returning the new sum. Only the letters will be printed out nothing else. The program will continue until the return is received at which time the sum of the digits will be printed on the next line. What was entered: a9 wF23’;/4i What the line actually shows: aA9wWFiI The sum of the digits is: 18

I dont understand why it expects more () in the functions....

View 11 Replies View Related

C++ :: Convert Input String Into A Form - Capital And Lower Case Letters

Mar 27, 2013

How can I write program that can convert an input string into a form that only the first letter of the string is a capital letter and the rest is lower-case?

View 3 Replies View Related

C++ :: String Find And Replace (Modified To Upper Case)

Feb 3, 2013

"C++ is a general-purpose programming language." I have to find the word "C++" and replace it with "Java" and then capitalize all letters.

#include <iostream>
#include <string>
using namespace std;
int main( ) {
string origin; //contains input string
string replace; //the string obtained by replacing "C++" with "Java"

[Code] ....

View 1 Replies View Related

C/C++ :: Converting String To Upper Case Via Dynamic Array?

May 21, 2014

I am trying to understand why i keep getting errors in my code. The errors are after the string is converted in my console window. I have to allocate and delete memory via dynamic array to do the problem.

#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main() {
string sentence;
int size;

[code]....

I just want to know why the extra characters are at the end of my conversion and how to make them stop.

View 3 Replies View Related

C++ :: Modify Contents Of 1D Character Array - Converting To Upper Case

Feb 10, 2015

I am unsure how to write a function which modifies the content of the 1D character array and puts all of the letter it contains into uppercase. the following are the letters which i am trying to convert.

char text[MAX+1] = {'T', 'e', 's', 't', 'e', 'r', EOT};

The output to this should look like T E S T E R EOT

View 2 Replies View Related

C :: Original Text File / Generate Another File With Text Content In Upper Case

Nov 29, 2014

Code software that, from an original text file, generate another file with the text content in upper case.For exemple:

entrence:

luke
tom
alex

outings:

LUKE
TOM
ALEX

My code so far:

Code:

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

[code]....

View 2 Replies View Related

C# :: Upper Pyramid Is Working Fine But Lower Pyramid Executes Infinite

Feb 10, 2015

I need to print like below pattern.

1
121
12321
1234321
123454321
1234321
12321
121
1

I got the upper pattern but below pattern is not working it executes infinte loop, how to reslove this.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ro {
class ro {
static void Main(string[] args) {
int numberoflayer = 5, Space, Number;

[Code] ....

View 1 Replies View Related

C++ :: Case Statement Not Working?

Mar 6, 2015

I have this case statement that is not performing as expected. For some reason ASE_OK and ASE_NotPresent both print out. Why is this? ASE_OK is a return value of 0 while ASE_NotPresent is -1.

Code: // Try to create the buffers and store it
switch (theAsioDriver->createBuffers(info, numChannels, bufferSize, callbacksInfo)) {
case ASE_OK:
std::cout << "ASE_OK";
input->bufferSize = output->bufferSize = bufferSize; // Buffer size is stored in both input and output
case ASE_NotPresent:
std::cout << "ASE_NotPresent";
errorMessage = "Could not find input or output devices.";
return NO_DEVICES_FOUND;

[code]....

View 3 Replies View Related

C :: Using Or Inside Case Arguments

Nov 6, 2013

I would like to choose same case for multiple switch conditions.

For example:
Code: switch(choice) //''if choice ==0 or choice ==1, chose same case''
{
case (0 || 1):
{
//execute steps
}
break;
default:
{
//execute steps
}
break;
}

The '||' inside case does not have the desired effect (although it compiles fine). How can I do it without using if-else statements.

View 1 Replies View Related

C/C++ :: Case Statement After Value Change?

Jan 5, 2015

I am building a tamagotchi like application/game. As for the leveling up and changing of character I am using a char value so that the icon can change as the character progresses.

Due to the fact that the value for level is changing I need it to also change for what is being used for the case statements

I know I cant use variables in case statements because I have tried every way I can think of.

The code is

switch(Area[y][x])
{
case '*':
Area[y][x] = Level;
break;
case 1:
{
CODE
}
}

Where I have the case 1 I need it to change as level increases (as level is starting at 1)

View 5 Replies View Related

C# :: Switch Case Variable Scope

Jan 31, 2014

Ran into something today that does not make sense:

This compiles: Code: int x = 5;

switch(x) {
case 0:
{
int value = 5;
}
break;

[Code] ....

Ok so it doesn't like int value = 6 b/c of int value = 5 for case 0. However since the value in case 0 is declared within the brackets one would think it has case scope.

So I tried this:

Code: int x = 5;
switch(x) {
case 0:
{
int value = 5;
}
break;

[Code] ....

Now it doesn't like it b/c value has not been declared in case 1:. These two conditions cannot possibly be both true at the same time. You cannot disallow the declaration of value in case 1 b/c it interferes with value in case 0 and at the same time disallow me to use value from case 0 b/c it is not in scope. If it was not in scope then theoretically I should be able to declare value in case 1.

Both MSVS 2012 and 2013 exhibit the same behavior. I checked the standard and it is unclear on the matter.

View 7 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 :: Program Keeps On Crashing When It Finishes Case 1?

Oct 18, 2013

The program keeps on crashing when it finishes case 1

View 5 Replies View Related

C++ :: Case Scope In Switch Statements

Dec 16, 2013

Is it's scope confined to that single case?

char ch;
switch(ch) {
case '1':
using namespace common::section1; //only this case??
break;

[Code] ....

View 8 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++ :: Getting Error - Case Value Has Already Appeared In Switch

Dec 11, 2014

I keep getting the error "case value has already appeared in this switch" how do I fix this?

switch (selection) {
case 'A' || 'a':
aFunc(Houses);
break;
case 'B' || 'b': //The error is here
bFunc(Houses);

[code].....

View 3 Replies View Related

C++ :: Comparison Of Two Strings (case Insensitive)

Apr 27, 2013

bool simpleQuestion::checkAnswer(string guess) const {
for (int i=0;i<qAnswer.length();i++)
if (qAnswer==guess)
return true;
else
return false;
}

This is my code and what im trying to accomplish here is making the comparison of the two strings (qAnswer & guess) case insensitive. I know i need to loop through each character of each string and for each character i can use toupper and every char in each string will become uppercase and therefore case insensitive. However, im not sure how to go about this; if any technique used to loop through each character of the string and how to use to upper.

View 2 Replies View Related

C++ ::  switch Case With Enum Types

Jul 4, 2014

I'm trying to convert the enum type {PG, R, G, PG-13, etc.} to strings so i can use it in cout statement but no matter what i put inside switch(), the compiler keeps saying Error: expression must have integral or enum type. What am I doing wrong exactly?

Movie covert_rating(Movie r) {
switch (r) {
case PG:
return "PG";
break;
case R:
return "R";

[code]....

View 4 Replies View Related

C/C++ :: Stopping Case For Asterisk Pattern?

Dec 1, 2014

So, I'm going to write a recursive function for a asterisk pattern but I'm stuck figuring out how to create a stopping case for it, better yet, I'm unable to describe the pattern completely.

*
**
-*
****
--*
--**
---*
********
-----*
-----**
------*
-----****
-------*
-------**
--------*

( - represent white spaces )

What I've been thinking:

* Every odd row has 1 * with 1 incremented white space

* Every "pair" of asterisks equals 8 total (EX. 8 one pair *'s, 4 two pair *'s, 2 four pair *'s)

Unfortunately, that's all I got. how I can represent this as I function. Once I figure out what my stopping case should be, I think I can do the coding on my own.

View 1 Replies View Related

C/C++ :: How To Compare Strings Ignoring Case

Oct 29, 2014

It should report whether or not, ignoring case, they are the same.

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

[Code].....

View 1 Replies View Related







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