zeroliken 79 Nearly a Posting Virtuoso

Maybe you should check if the next largest number being checked in the next loop is less than the current largest number

zeroliken 79 Nearly a Posting Virtuoso

what do u mean repeat steps for all literations

do a condition when "i" is equal to 4,5,6, etc
where each condition's inner loop is used to print a specific nuber of "*"

zeroliken 79 Nearly a Posting Virtuoso

Also don't forget to wrap your codes in code tags and properly indent it cause it's an eyesore

zeroliken 79 Nearly a Posting Virtuoso

It's only a code snippet and not complete its your job to change those variables to a number you want

I'm only showing it as a guide not as an answer

zeroliken 79 Nearly a Posting Virtuoso

Next time wrap your code in code tags and properly indent it

You should make an inner loop work according the number showing at the outer loop
Pseudo:

for(int i=0;i<7;i++){   //outer loop
    if(i==0 ||  i==1){                    //condition used to tell which loop to use
       for(int j=0;j<numberofstars;j++){  //inner loop used to print *
           System.out.print("*");
           }
       System.out.print("\n");   //just to show a newline
    }
    else if(i == 3){
         for(int j=0;j<anothernumberofstars;j++){
           System.out.print("*");
         }
          System.out.print("\n");   
    }
    //repeat steps for all iterations
}
zeroliken 79 Nearly a Posting Virtuoso

in this assignment
make the program read 10 integers and store them in an array. Then,
pass this array to a method that finds the largest integer in the array, and
counts its occurrences. Your method should return a string of the form
largestNumber > occurrenceCount. Then in the main method print
the returned string. Also, repeat the process until the user declines to con-
tinue. Here is a sample run:
Enter 10 integers: 1 11 7 12 4 2 12 1 5 12
Largest No->Occurrence Count : 12->3
Again? Enter Y or N
N

I don't think that there's a need to compare the MAX and MIN values if you imply what you learned from stultuske's last post as you've already completed your assignment requirements

zeroliken 79 Nearly a Posting Virtuoso

The problem is in c, unlike java, has no support for a GUI
You could make your program work as c has a support for structures and linked lists but you'd have no choice but to remove the use of windows and buttons if your gonna convert it to c

zeroliken 79 Nearly a Posting Virtuoso

Wrap code in code tags

You know you could have also said to properly format the code cause it's still hard to read

zeroliken 79 Nearly a Posting Virtuoso

For me I'd use a loop to store the character in an array

zeroliken 79 Nearly a Posting Virtuoso

seee i told u i have it on my frinds labtop not on mine ! :( please cxould u just help me its due tommorow

You know you could make one right now if it's that important

zeroliken 79 Nearly a Posting Virtuoso

u dont understand i really need this i tried so much please !!!!!!1
ill teel u what i did for the program i wrote up till 20
i did
public class
puclic static void main string args
int= "one, Two,Three,........ till 20)
and i did system.out.print ln something i forgot what itwas

Try to post your complete program

public class //missing class name?
puclic static void main string args //public static void main(String[] args)
zeroliken 79 Nearly a Posting Virtuoso

Printout a welcome message
Make a loop containing your question
then ask if the user wants to continue
then make the loop run while the user inputs yes otherwise the loop will stop ending the program

We're willing to help you as long as your willing to help yourself
post your code showing the effort you've made so far in coding your program

zeroliken 79 Nearly a Posting Virtuoso

Hello, I've been having a lot of trouble with a variable type called "float64". I'm trying to create a do{}while loop to make the number count up each time. data is also defined as an array.

float64		data[1];
int         i;
	do{
		for(i=0;i<1;i++)
		{
		data[i]=data[i]+.01;
		if(data[i]>9.99)
			data[i]=-9.99;
		}
}while('0'=='0');

Any guidance would be appreciated. Also, this MUST be float64, so no other variable can be substituted for it. Thank you.

Your instruction is not clear, what do you mean by "I'm trying to create a do{}while loop to make the number count up each time."

while('0'=='0');

...So it runs while the value of 0 is 0... :?:

zeroliken 79 Nearly a Posting Virtuoso

i have to make it with stars

you could use loops that prints out asterisks

zeroliken 79 Nearly a Posting Virtuoso

your dividing a double from an int... change total's data type to double

zeroliken 79 Nearly a Posting Virtuoso

Sorry for my code that does not following the format..
Where do you notice that the output is zero? I try looking at my code but cant figure it out.
I'm very new to C programming so sorry... if i come
across as stupid!

Acent  = a / total * 100  ;

right after this line printout Acent's value

zeroliken 79 Nearly a Posting Virtuoso

Y and N have no values if you want to check if the user used either then compare it to the letter itself e.g.

if(query == 'Y')

also

printf("That will be $%d, confirm? (Y/N)\n", price*numofbees);

price is a float, &d is used for integers use %f

zeroliken 79 Nearly a Posting Virtuoso

hmm sory what do you mean by code that isn't formatted.?

There's a link posted on WaitP's post

Anyway check the Values of Acent to Fcent...did you notice that their output is 0

zeroliken 79 Nearly a Posting Virtuoso

Here's an example on using atof

#include<stdio.h>
#include<stdlib.h>
 
int main(void)
{
double a;
char c[10];
scanf("%s",c);

a=atof(c);
printf("%lf\n",a);
return 0;
}
zeroliken 79 Nearly a Posting Virtuoso

Its just an example only for a sine calculator atof just basically changes a string to a float (double)
e.g.

n = atof (Input); //where n is a double and Input a string
zeroliken 79 Nearly a Posting Virtuoso

Like this? But how do I convert 2 strings to double? Need I use strcat?

#include<stdio.h>

char c[101],d[101];
main()
{
scanf("%100[^.].%s",c,d);
printf("%s.%s",c,d);


return 0;
}

use atof

zeroliken 79 Nearly a Posting Virtuoso
double a;

include this in the main function

printf("%.2lf\n", a);

.(anynumber) represents the number of decimal places you want to output

or just do the solution posted by WaitP to be exact

WaltP commented: Doesnt come anywhere near the answer. -4
zeroliken 79 Nearly a Posting Virtuoso

5. Factors of a whole number
Divide the n number by numbers ranging from 1 to n using a modulo then check if the answer is equal to 0, if not then list down the number

6. Acceleration of an object given any number of velocities
Is time given?

7. Density of an object given its mass and weight
Convert weight to volume then divide mass from the volume

8. Force in Newton's given mass and acceleration
F=m*a... Is it that hard?

10. Determine if a number is prime
You need to check if the given number is not divisible by any number other than itself or 1 so divide the number ranging from 2 to the number before the given number using a modulo...if one of the answers is equal to 0 then its not a prime number

zeroliken 79 Nearly a Posting Virtuoso

Is it showing a compiler error? post the errors
Is it showing unwanted output? post the output
Do you know how to properly format your code and wrap it it in code tags before you post? If yes then do so

zeroliken 79 Nearly a Posting Virtuoso

"If" he has no problem with the code he posted then the remaining problems he wants suggestions must be from numbers 10,8,7,6,5

zeroliken 79 Nearly a Posting Virtuoso

Yes i can convert the datatype.But then i don't know,
how to convert char '3' to int '3' OR int a to char 'a'

Read this
atoi

and include this library

#include <stdlib.h>

then read this
convert char to int

zeroliken 79 Nearly a Posting Virtuoso

What I mean to say is that if there is no statement inside the while loop that changes the value of ch or a break statement the program will run continuously

while((ch=getch())!=27)
	{
		if (ch == '@') break; //Just so that we have a known exit.

If ch has a value different from 27 and @ and there is no other statement that changes its value then it will run continuously

why not use a boolean like statement that asks the user if he wants to continue?
pseudo:

int ans = 1;
while(answer==1){
      //ask user if he wants to continue..presses 1 if yes 0 otherwise
      if(userinput==0){
         ans=0;
         }
      }

whoops change answer to ans at line 2 at the while statement :)

zeroliken 79 Nearly a Posting Virtuoso

Start here:
How to Draw a Rectangle in Java

If you read and learn and not just copy paste the codes then you should be able to go on from here or post your current code if you got a problem with it

zeroliken 79 Nearly a Posting Virtuoso

a constructor that returns a String and a Double?
I assume you ment:
Make a constructor which takes a String and a double (lowercase d) as parameters?

Yup I meant that, my post didn't match the one on my mind...thanks

zeroliken 79 Nearly a Posting Virtuoso

In lines 20,23,28,31
The correct conversion specifier for doubles is %lf when using scanf

zeroliken 79 Nearly a Posting Virtuoso

//while((ch=getch())!=27)
gets the characterin ch and chek its value but i know this will work only once and
not for all the inputs

What I mean to say is that if there is no statement inside the while loop that changes the value of ch or a break statement the program will run continuously

while((ch=getch())!=27)
	{
		if (ch == '@') break; //Just so that we have a known exit.

If ch has a value different from 27 and @ and there is no other statement that changes its value then it will run continuously

why not use a boolean like statement that asks the user if he wants to continue?
pseudo:

int ans = 1;
while(answer==1){
      //ask user if he wants to continue..presses 1 if yes 0 otherwise
      if(userinput==0){
         ans=0;
         }
      }
zeroliken 79 Nearly a Posting Virtuoso

Do you have prior knowledge of using graphics class in java?

zeroliken 79 Nearly a Posting Virtuoso

at the while statement starting at line 151 is there a line/statement that changes the value of ch?

zeroliken 79 Nearly a Posting Virtuoso

I was checking other threads then came back here only to find that JamesCherrill found the solution so simply:-O
Took me a while to see that...Just goes to show the difference in experience

@OP
sorry wasn't much help:$

zeroliken 79 Nearly a Posting Virtuoso

t.setName(name);

where can setName method be found?

zeroliken 79 Nearly a Posting Virtuoso

Did you post your whole code? Are the classes in separate java files? wheres the public class?

zeroliken 79 Nearly a Posting Virtuoso

post the whole error message from the compiler

zeroliken 79 Nearly a Posting Virtuoso

Sure I would understand you better if you post your whole code

zeroliken 79 Nearly a Posting Virtuoso

To me it depends on my mood, importance and focus at night... Iv'e experienced not sleeping for a whole night just to program and some nights I don't feel like typing at all :P

zeroliken 79 Nearly a Posting Virtuoso

post your code and make the instructions clear no one here's gonna do all the work for you

zeroliken 79 Nearly a Posting Virtuoso

The program sounds fun so I did it myself..used a whole mess of if else statements inside an inner loop...though the program might be simplified if you use a recursive function but I'm not sure how to do this yet

zeroliken 79 Nearly a Posting Virtuoso

your initializing public String loadTicket(int tNumber) method inside public String createTicket()... your missing a bracket

also the lines where the errors are found does not match your posted code

zeroliken 79 Nearly a Posting Virtuoso

okay and kbhits works for only getche and getch.So what can i use if i read a varialble by scanf or by other ways???

How about any keys in the alphabet instead of using getch() or the ESC key

zeroliken 79 Nearly a Posting Virtuoso

Make a constructor in the Product class that returns a String and a Double only

zeroliken 79 Nearly a Posting Virtuoso

At the loop, whenever the boolean equals true the number of times the value has appeared in the Arraylist will be added by one(call augmentOccurences) else new number has appeared then add the number in the ArrayList

I believe stultuske has explained it well already

zeroliken 79 Nearly a Posting Virtuoso

ok bt 27 is its ascii value.

I know ...
check this link for more info ESC key in c

zeroliken 79 Nearly a Posting Virtuoso

Make a main class that calls the methods posted by stultuske

Do you know how to use separate classes?

zeroliken 79 Nearly a Posting Virtuoso

use a loop to traverse the linked list then compare the current value to the next to exchange the positions if needed

zeroliken 79 Nearly a Posting Virtuoso

type entire prog

AND type in English the messages as wellas the variable name.Its hard to uderstand.

if the OP is not english oriented then it's alright if the code itself is not in proper english as long as it is properly formatted and maybe commented on important parts so as to help us pass the language barrier in helping

zeroliken 79 Nearly a Posting Virtuoso

how to sorting this, i've problem to sort by jum_nilai from the highest until smallest

void lihatData(void)
{
    if(pertama==NULL)
       printf("Data tidak ada !!!");
    else
    {
        printf("%3s %-20s %-12s %-5s %-7s %-7s %-5s %-5sn","No","Nama","Jenis K","N Mtk","N B.Ind","N B.Ing","N IPA","Jumlah");
        printf("--- -------------------- -------------- ------- ------- ------- ----- -----n");

        sekarang=pertama;

        do
        {
                printf("%3d %-20s %-12s %-5d %-7d %-7d %-5d %-5dn",
                sekarang->nomor,
                sekarang->nama,
                sekarang->jenis_k,
                sekarang->nilai1,
                sekarang->nilai2,
                sekarang->nilai3,
                sekarang->nilai4,
                sekarang->jum_nilai);
        }

        while((sekarang=sekarang->next) != NULL);

    }
} 

end-quote

what do you mean by sort from highest to smallest? the length of the strings?

also wrap your code in code-tags and post the complete code