zeroliken 79 Nearly a Posting Virtuoso

Which part are you having problems with?

zeroliken 79 Nearly a Posting Virtuoso

Edit: just noticed that the do while should be in the method

zeroliken 79 Nearly a Posting Virtuoso
#include <stdio.h>

void main()
{
    int d,m,y;
    int days=0;
    int k;                            // return var
    printf("input date dd.mm.yyyy\n");
    scanf("%d.%d.%d",&d,&m,&y);
    m--;
    switch(m)
    {
        case 11:days=30;
        case 10:days+=31;
        case 9:days+=30;
        case 8:days+=31;
        case 7:days+=31;
        case 6:days+=30;
        case 5:days+=31;
        case 4:days+=30;
        case 3:days+=31;
        case 2:if((!(y%4))&&(y%100))
                   days+=29;
               else if(!(y%400))
                   days+=29;
               else
                   days+=28;
        case 1:days+=31;
        case 0:break;
    }
    k=leap(y);
    printf("days:%d\nleap year:%d\n\n",days+d,k);
}

int leap(int year)
{
    int k;
    if((!(year%4))&&(year%100))
        k=1;
    else if(!(year%400))
        k=1;
    else
        k=0;
    
    return k;
}

please refrain from doing the OP's work for him
read this:http://www.daniweb.com/software-development/computer-science/threads/573
and use int main instead of void main
read this: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1044841143&id=1043284376

zeroliken 79 Nearly a Posting Virtuoso

for your last code you can't use a continue statement if it's not in a loop

next, why not just input a new value for numAccident if it's less than 0 like so?

int getNumAccidents (string instance)
{
	int numAccidents;
	cin >> numAccidents;
        while(numAccidents<0){
            cout << "enter value greater greater than or equal to 0" << endl;
            cin >> numAccidents;
        }
	return numAccidents;
}
zeroliken 79 Nearly a Posting Virtuoso

The number of accidents in a year cannot be negative, so only a value of 0 or greater is an acceptable input.

how about an if statement or a loop where if the user inputs a number less than 0 then the user must input another number

zeroliken 79 Nearly a Posting Virtuoso

use a loop where the condition is while the user doesn't enter a specific number it will continue to loop and insert it around the user input and switch case

example:

while(menu != 4){
printf("Please choose your menu: ");
	scanf("%d", &menu);
switch(menu)
{
case 1: quiz();
        break; //don't forget to use break otherwise it will ran through other cases
case 2: calculator();
        break;
case 3: optional();
        break;
case 4: printf("Goodbye\n");
        break;
default: printf("I'm sorry, but you have enter an invalid selection. Please try again.");
        break;
}
}
zeroliken 79 Nearly a Posting Virtuoso
zeroliken 79 Nearly a Posting Virtuoso

I didn't know that me and most of the people I know are nomophobic till I read this

zeroliken 79 Nearly a Posting Virtuoso

Ah I see he exactly copied the code from the link I provided as an example in the other thread yet he didn't even bother to check the comments about that code...

My intention was just to show him just an example of how a phone book program could possibly look and work like... was I wrong to show him that :(

I do hope the OP makes his own phonebook program instead of using exactly this code from that link and he's just using this to learn

zeroliken 79 Nearly a Posting Virtuoso

Hmmm... why hasn't anyone suggested Geany ;)

zeroliken 79 Nearly a Posting Virtuoso

As I can see you might need to import java.lang.Math to make Math.pow and Math.sqrt to work

zeroliken 79 Nearly a Posting Virtuoso

once I figure out how to open the image

For basic image handling I suggest the Toolkit class
here's a tutorial
http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter06/images.html

zeroliken 79 Nearly a Posting Virtuoso

What have you gotten so far?

zeroliken 79 Nearly a Posting Virtuoso

in your previous code

public CircleComponent(Point2D.Double point)
   {
      circle = new Circle(200, 200, 100, Color.BLACK);
      final double SMALL_RADIUS = 3;
      Color color;
 
      if(Circle.isInside() == true)
         color = Color.GREEN;
      else
         color = Color.RED;
      smallCircle = new Circle(point.getX(), point.getY(), SMALL_RADIUS, color);
   }

@ line 7
Java is case sensitive that would be circle.isInside(/*argument*/) since circle is your new Circle object
plus yoou need an argument that has the same argument type for public boolean isInside(Point2D.Double p)

zeroliken 79 Nearly a Posting Virtuoso

--var is predecrement where var is decremented before being used
and var-- is postdecrement where var is decremented after being used.

zeroliken 79 Nearly a Posting Virtuoso

create the bank account task using structure and Files concept in c.

In what way may we help you... other than do the homework for you

zeroliken 79 Nearly a Posting Virtuoso

Guys you could have just simply used the flag bad post button on the left side of the post to get a mod's attention to get this thread moved to the web development forum, there's no need to argue about this

dantinkakkar commented: You settled it out, but why give a -1 repo to a new guy who has no idea about this? +3
zeroliken 79 Nearly a Posting Virtuoso

check the java tutorials on applets
http://docs.oracle.com/javase/tutorial/deployment/applet/

For displaying in a webpage, After creating an applet file the .class file should be invoked within an HTML page by using the <APPLET> tag

zeroliken 79 Nearly a Posting Virtuoso

a lot of members will hate you If you go around posts telling them to mark their threads as solved while you have no proper contribution for the thread's solution, they'll think you just want to get your solved counts up like a parasite

zeroliken 79 Nearly a Posting Virtuoso

Is there a finish method in the other codes?
If so put it in this class too or just create a method finish()

zeroliken 79 Nearly a Posting Virtuoso

Is it required to use maxChoice or is it not really necessary cause you did not refer to it for the process?
plus you did not use these variables too

int choiceA = 1;
int choiceB = 2;
int choiceC = 3;
int choiceD = 4;
zeroliken 79 Nearly a Posting Virtuoso

Did you search at google for various examples... here's one I found though it's a bit incomplete but has the functions you need

http://stackoverflow.com/questions/7911919/sorting-array-from-typedef-struct-in-c

zeroliken 79 Nearly a Posting Virtuoso

Here's a link for the text color
text color

zeroliken 79 Nearly a Posting Virtuoso

What have you gotten so far?
Is there a specific problem with the code or you haven't started yet?

zeroliken 79 Nearly a Posting Virtuoso

I think we dream so we don't have to be apart so long. If we're in each others dreams, we can be together all the time.

- Hobbes (from the comic strip, Calvin and Hobbes)

zeroliken 79 Nearly a Posting Virtuoso

It's not really a bug, the modulus is doing whats its suppose to do

are you trying to make the program display 0 when 30 or a similar case is entered?

zeroliken 79 Nearly a Posting Virtuoso

I think that integers are 4 bytes long

zeroliken 79 Nearly a Posting Virtuoso

i need a program in c the program is their is a file in that first we have take 0-9 letters in that we count how many no of a,b,c...,z then we take 1-10 we do the same we do the same sequence until the end of the file.

Sorry to say this but we're not a coding service meaning we don't provide code but only helps members from theirs

If you need further help start a new thread (instead of replying to an old one) if your troubled by a problematic code

zeroliken 79 Nearly a Posting Virtuoso

^yes we'd more than happy to help if you post it here where any member can see and give their help and suggestions

and please remember to wrap the code in code tags

zeroliken 79 Nearly a Posting Virtuoso

wrap the code between

tags so we can see where line 56 is

zeroliken 79 Nearly a Posting Virtuoso

yes remove it, start at 0 and make the condition less than 10

after that you need to change a few counters with your bubble sort to make it work

zeroliken 79 Nearly a Posting Virtuoso

assign values to a1[j] in the loop and b1[j] in the other

Edit: glad that's solved you mark this as solved then

zeroliken 79 Nearly a Posting Virtuoso

At line 9;
An array has elements ranging from 0 up to size-1, you can't start at 1 there and end with 10+1

zeroliken 79 Nearly a Posting Virtuoso

okay...as you can see there your not assigning values to the arrays(shown by the 0s),
assign values to a1 and b1(with their respective indexes using the loops) instead of the variables val and val2

zeroliken 79 Nearly a Posting Virtuoso

At line 13 and 25, your not assigning values to your arrays indexes but just to variables you never used, try printing out the values of a1[j] and b1[j] at the next line to see what we mean

zeroliken 79 Nearly a Posting Virtuoso

Is the 5% constant or does it change depending on the current tuition fee?

if it's the latter, you can make use of the first loop and make it loop up to 21 years(if it's allowed) then if it's the 18th year add the current tuition up to the 21st year and store it in a variable, just to be sure of the values

though if it's constant or if you already know the tuition value for the 18th year and your positive that the values up to the 21st year are correct then go ahead if you prefer this

zeroliken 79 Nearly a Posting Virtuoso

check line 45

...and the number of t's in the filename there ;)

zeroliken 79 Nearly a Posting Virtuoso

Once you use a character array you need to make specific changes in the program

for example:

scanf ("%i", &password[7])

will be changed to %s for the string input

By changing it to a char array you should be able to make the neccesary changes in the code to make it compatible but if you still need further help with this you could always post all the error messages and their corresponding lines where they're found

P.S. there's no need to downvote WaitP's post, he posted the first step for the solution :)

zeroliken 79 Nearly a Posting Virtuoso

include the header

#include <ctime>

Edit: I change my mind,you should have posted this in the C forum
i think its

#include <time.h>
zeroliken 79 Nearly a Posting Virtuoso

whoops didn't notice my math error, sorry about the example that's not suppose to be D(9) but D(11) :$

anyway about the recursion you need a base case where the recursion will eventually lead to for all values passed on to it,
in your code if the value of int doesn't equal to 10 it will keep on running, The + n won't apply yet until a value is returned for D(), maybe make a base value where all numbers will eventually lead to like if it becomes less than or equal to 0

zeroliken 79 Nearly a Posting Virtuoso

the stackoverflow happens because of an infinite recursion

the value 10 is not the base value, you need to have a condition for the values less than 10 or at least less than or equal to 0

for example D(21) will result to D(9)+10 then (D(-1)+10)+10 and so on

zeroliken 79 Nearly a Posting Virtuoso

Dear All,
I want to read ini file for configuration. Who can send me a simple code?
Thank you in advance
Hoshang

Sorry to say this but we're not a coding service meaning we don't provide code but only helps members from theirs

If you need further help start a new thread (instead of replying to an old one) if your troubled by a problematic code

zeroliken 79 Nearly a Posting Virtuoso

yes, here's a link for an example
http://www.javaswing.org/java-cardlayout.aspx

zeroliken 79 Nearly a Posting Virtuoso

Thanks!

Glad that's solved but please next time post a reply for your thread instead of changing the whole original post

zeroliken 79 Nearly a Posting Virtuoso

I think you only need 2 loops to do it
I suggest you do it in pencil and paper first and check the algorithm before coding :)

zeroliken 79 Nearly a Posting Virtuoso

try putting the while loop at the end of the for loop(or at different parts beginning, after the scanf, etc.) and see if it helps

zeroliken 79 Nearly a Posting Virtuoso

Could you post the whole code so I can have a better look at it...

zeroliken 79 Nearly a Posting Virtuoso

Well I got it to work... try commenting out the while loop and it skips the fgets

#include<stdio.h>
int main(void){
	char name[30];
	int c,r;
	printf("Enter number");
	scanf("%d", &r);

	while ((c = getchar()) != '\n' && c != EOF);

	printf("Enter name");
	fgets(name,sizeof(name),stdin);
        return 0;
}
zeroliken 79 Nearly a Posting Virtuoso

is the problem something like fgets getting skipped after receiving an int from the user?

zeroliken 79 Nearly a Posting Virtuoso

pseudocode:

//get input from user
for(int i=1; 1<=12; i++){ //use a loop
    answer = i*input;
    //print out the answer along with the input and the counter
}