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


ADVERTISEMENT

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 View Related

C :: Scanf With Stopping Condition

Mar 22, 2013

I wanted to input some numbers with scanf function, i can enter some numbers and if I input -1 to the scanf, the input must end. And the scanf function has limited input, the max that I can input is 40 numbers.example if enter 1 2 4 6 5 4 -1 the scanf function will ended and the result will be appear.I wanted to know how the scanf function is like that would be best for this problem, Code: scanf("%d", &n); the result if I input those number will be like

|
||
||||
||||||
|||||
||||

View 3 Replies View Related

C++ :: Stopping Threads Without Using Local Var?

Aug 31, 2014

Here's my code,

#include <iostream>
#include <unistd.h>
#include <thread>
using namespace std;
void Blink();

[Code] .....

The problem is i don't want to use local vars , is ther anyway do end the loop safely(removing all the vars used in function and etc) without using a local var ?

View 3 Replies View Related

C++ :: Stopping Codes With A Key Press

Feb 25, 2013

I have a program that I made, which does a list of stuff, then checks if a key is pressed, and if it's pressed, stop the looping.

The problem is, it checks if the key is pressed once a loop, which means that if the list has delays, you have to hold the button down for a while (depending on the list).

Here's an example:
Move mouse;
Pause program for 2 seconds;
Move mouse;
Pause program for 2 seconds;
Check if key is pressed;

What ways can I fix this problem?

View 1 Replies View Related

C++ :: Stopping Infinite Loop?

Feb 20, 2013

The code below gives me the maximum odd number and the minimum even number of a list of numbers that the user type. However, for the loop to stop the user needs to type 1000. Is there a better way (without having to have a "stopping" number, just in case I need this number to be somewhere on the list) to get the same results?

Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main() {
int x, maxi, mini;

[code]...

View 2 Replies View Related

C/C++ :: Read Numbers From Cin Then Sum Up And Stopping When 0 Entered

Jun 6, 2014

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Add the following to your program:

-A counter within the while loop that keeps track of the number of inputs entered.
-A comment that determines if the total value is less than 100 or greater than 100, as in the sample output
-Switch statements to determine the total number of inputs

Sample output:

Enter numbers, one per line. Enter 0 to end:
7
8
6
5
5
9
8
0

The total was 48.
The total number of inputs read is 8.
The total is less than 100.

The code that I've got so far lets me keep track of the inputs entered, and displays the total of the values, but I'm not sure how to do the part where it determines if the value is greater or less than 100.

#include <iostream>
using namespace std;
int main() {
int val, total=0;
int i=0;
cout << "Enter numbers, one per line. Enter 0 to end:
";

[Code] .....

View 2 Replies View Related

C Sharp :: Stopping And Resuming Threads?

Jul 9, 2012

how do I stop and restart a Thread in C# once it reaches a certain location on a form then restart the thread once it goes outside of the location boundries?

I am trying to stop an animation thread (a bullet) once it reaches a block on a panel.

View 1 Replies View Related

C :: Shows Lines Of Running In Output With Gdb Without Stopping

Feb 24, 2013

I run the program with gdb , i searched but find nothing about how i could run gdb , that shows what line of code is running constantly (i rather it also shows value of the variable on each line if it's possible ) without stopping (i mean i don't want to enter "step" every time , i just need to run the program with debugger and shows line of the code is running (without need to enter step each time by myself)is it possible? if yes , what command is needed to start gdb for this purpose?

P.S: for this purpose if i have to set breakpint i will. but even i rather not set breakpoint , i rather gdb while running the program shows what line is now executing (rather with the value of variabels).

View 4 Replies View Related

C/C++ :: Polymorphism Is Stopping Short Of Desired Class

Mar 2, 2014

I've been working on this project which inserts data for different types of books lately, and I'm trying to utilize inheritance and polymorphism. The issue I've been having is after I create an object with my MediaFactory, I go to insert data into that type of object, but it won't reach the correct child class. The parent class in this case is MediaData. The class I'm trying to reach is Childrens, and the class that falls in between is called Book. The function I'm calling to insert the information is setData(ifstream&). This function simply places the information from a txt file into an object with the insertion operator.

Right now the program runs into the setData function of Book instead of Childrens. I need Childrens so I can enter all the required attributes (title,author,year). The call to this function is in MediaManager through the function called buildMedia, and my test is running into the case if (type == 'Y'). From there a pointer of type MediaData is created and pointed to a new object returned of type Childrens. I'm using my debugger in Xcode which does show that the correct object type (Childrens) was created.

I've tried a couple things so far. First I created another function called getData. From there I passed in *media and infile (txt input file) into that function, which then passed it right into setData with a pointer to the object and infile in the parameter. That didn't work, so I also tried going back into Childrens and removing MediaData from all my virtual functions and replacing it with Book. I got the same result when that happened; It morphed into Book class instead.

I have a portion of my UML as a reference. Childrens is a Book; Book is a MediaData. I also included all code for MediaManager, MediaHash, MediaFactory, MediaData, Book, and Childrens.

I did not include the operator overloads in the .cpp files to eliminate some redundancy.

//-----------------------------------------------------------------------------
// MediaManager.h
// Manager class for MediaData type objects
//-----------------------------------------------------------------------------

#ifndef MediaManager_H
#define MediaManager_H
#include "MediaHash.h"
#include "MediaFactory.h"
#include "MediaData.h"
using namespace std;
class MediaManager {

[Code] ....

View 3 Replies View Related

C/C++ :: Stopping A Game When Winning Score Is Reached

Nov 11, 2014

I'm working on coding a game of pong that allows players to play until one reaches a score of 10. Once the winning score is reached I want to display a "Game Over" message stating which player won. The game works perfectly except for stopping when the winning score is reached.

Here is the code I have so far:

//pongTest.cpp
#include "stdafx.h"
#include <string>
#include <Windows.h>
#include <iostream>
#include <conio.h>
#include <sstream>
#include <math.h>
#include <glgl.h>
#include <glglu.h>
#include "GL/freeglut.h"

[Code] ....

Not sure if my gameOver() function just isn't written properly, I'm not calling it properly, or a mixture of both.

View 2 Replies View Related

C :: What Is Left Most Asterisk Doing

Apr 1, 2014

I encounter this from a library:

( *(reg8 *)(pinPC) |= CY_PINS_PC_DATAOUT)

From my understand the cast (reg8 *) applies to the result of the bitwise OR. But what is the left most asterisk doing?Is it just dereferencing the casted pointer?

View 1 Replies View Related

C++ :: Asterisk Bar Graph

Feb 12, 2014

i have to make a programs that prompts the user to enter quiz grades and add them up. For examples the user enters 6 test grades they are out of 5 so he enters 0-5 and i store them in the array. This part works great but now i have to print out a bar of vertical asterisks for every part too. So if at the end we have one test grades that are 2 grades of 1 points, 1 grade of two point, 2 grades of three point and 1 grade of 5 point it will have to display them as this

There are 2 grades of 1
There are 1 grades of 2
There are 2 grades of 3
There are 1 grades of 5

i need to do for loops but i am stuck on what to count too and what to print i know i will need cout << "*" and a couple of spaces.

#include <iostream>
using namespace std;
int main (){
int size;
int tests;
int a[6]={0};

cout << "How many quiz scores will you enter: ";
cin >> size;

[code]....

View 1 Replies View Related

C :: How To Change The Numbers Into Asterisk

Oct 10, 2014

i have my basic C program here (i'm new to C language):

Code:

#include <stdio.h>
int main()
{
int grade;
int A=0;
int B=0;
int C=0;
int D=0;
int E=0;

[Code]....

As you can see, it's only for counting how many students got the grades from A to E, but the problem is that i need to change it from numbers into asterisk

for example: 4 students got the grade A, and 3 students got the grade B

instead of displaying

A=4
B=3

i want it to display

A=****
B=***

View 11 Replies View Related

C++ :: How To Change Password Input To Asterisk

Mar 6, 2015

Code:
#include <iostream>
#include <string>
using namespace std;

int main()

[Code] ....

View 6 Replies View Related

C :: Nested Loops - Asterisk Diamond

Jul 11, 2013

Getting close but I think I am stuck on the second loop. The input you put in will be doubled (and it's not supposed to).

Code:
int main() {
int n, i, j, k;
printf("What would you like the height to be? (Positive odd integer)
");
scanf("%d", &n);

[Code] .....

View 3 Replies View Related

C++ :: Place Two Asterisk Triangles On Top Of Each Other But Only Using 3 For Statements

Oct 19, 2014

I have to place two asterisk triangles on top of each other BUT only using 3 for statements. I have gotten the first one:

for(int a=1;a<=10;a++) {
for(int b=1;b<=a;b++)
cout << "*";
cout << endl;
}

I need the output to look like this:
*
**
***
****
*****
******
*******
********
*********
**********
*
**
***
****
*****
******
*******
********
*********
**********

The only kicker is I can have a total of 3 nested for loop statements.

View 7 Replies View Related

C++ :: Asterisk Diamond Is Printing Out Wrong

Sep 6, 2014

I feel as if I'm so close and I'm just messing up a value somewhere, but I am at a loss as to what I should change. Here is my code:

#include "stdafx.h"
#include <iomanip>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) {

[Code] ....

View 2 Replies View Related

C++ :: How To Produce Password Field With Asterisk

Sep 2, 2014

void Log_In() {
system("cls");
gotoxy(30, 30);
time_t now;
time(&now);

[Code] .....

How to produce a password field with asterisk ****** .....

View 1 Replies View Related

C/C++ :: Printing Asterisk Along A Function Of Y Columns

Jun 18, 2014

The assignment is to plot the functions, by implementing a function having the following prototype:

void plotPoint(double y);

This function should print a single "*" symbol, in a position determined by the value of y, and then a newline. The position of the * symbol can span over 80 columns: each column should represent a delta of length 0.1 in the value of y, and the zero should be placed on the 40-th column.

For example:
• placePoint(0) should print the * symbol on the 40th column
• placePoint(0.1) should print the * symbol on the 41st column
• placePoint(1) should print the * symbol on the 50th column
• placePoint(-1) should print the * symbol on the 30th column

Here is what I have so far:

#include <iostream>
#include <cmath>
int a;
int b;
int x;
int y;
int Func1(double a, double b )/>

[Code] ....

I'm lost now as to where to go to plot. I know that depending on the option chosen I call the corresponding function to return a value for y which is just then plugged into a function to plot it on columns of y.

View 6 Replies View Related

C++ :: Why Asterisk Required On Smart Pointers For Assigning Value

May 19, 2013

When i try to compile this code it gives me a error during run-time saying "*program name* has stopped working"

Code:
#include <iostream>
#include <memory>
using std::cout;
using std::endl;
using std::unique_ptr;

[Code] .....

Why is this happening? Also why do you need the asterisk on smart pointers to assign them a value? Is it just because, or is there a reason.

View 5 Replies View Related

C++ :: Utilizing Arrays Create Vertical Asterisk Graph?

Jun 25, 2013

This program needs to display a vertical graph of asterisks showing production for each plant in the company ...

Here is what I have so far:

***********************************
This program will read data and
display a vertical graph showing
productivity for each plant.
Reference Display 7.8 pg. 401-3
***********************************
*/
#include <iostream>

[Code].....

View 1 Replies View Related

C/C++ :: Encrypting Password To Be Inputed And Printing It As Asterisk Format

Sep 14, 2014

#include<stdio.h>
#include<conio.h>
#include<string.h>
char str1[20], str2[20]="kent";
main() {
printf("Enter your Username: ");
scanf("%s",str1);

[Code] ...

View 1 Replies View Related

C/C++ :: Can't Get The Right Square Pattern

Jul 4, 2014

I've been working on this code that should be looking like

1 3 5 3 1
3 5 7 5 3
5 7 9 7 5
3 5 7 5 3
1 3 5 3 1

but mine appears like this

1 3 5 3 1
3 5 7 5 3
5 7 9 7 5
3 3 5 7 9
1 3 1 3 5

This is the code I've got for now, I just don't know which logic I need to fix

int main(){
int r;
cout << "Rows?" << endl;
cin >> r;
for (int i = 1; i <= r; i+=2){
for (int j = i; j <= r+i; j+=2){
cout << j<< " ";
} for (int k = i+2; k >= i-1; k-=2){

[code]....

View 2 Replies View Related

C++ :: Display A Pattern Using Loops

Oct 17, 2014

I have spent at least an hour trying to display this pattern and I am not getting anywhere.

Pattern C
1
21
321
4321
54321
654321

This is as far as I got
#include <iostream>
#include <iomanip>

[Code]....

View 4 Replies View Related

C/C++ :: Nested For Loop Pattern?

Nov 3, 2014

I'm trying to output a pattern using loops. The pattern is a plus symbol made of 3 rows of 5 x's followed by 3 rows of 15 x's and finally 3 rows of 5 x's.

I can get the program to output all 9 rows with 5 x's but I don't know how to do the 3 rows of 15 in the middle. I have tried a while loop and also an if statement but nothing seems to work.

#include "stdafx.h"
#include <iostream>
#include <iomanip>

[Code]....

View 8 Replies View Related







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