Jump to content

[HELP]Me ena kodika se java ( new)


Recommended Posts

Posted

hi exw liges ores pou asxoloume kai piramatizome...lipon exw kanei edw auto to code

 

import java.util.*;
public class test {
public static void main (String args[])
{
	//Metavlites
	int sokolates;
	int fagomenes_sokolates;
	int eminan;

	sokolates = 400;

Scanner Keyboard = new Scanner(System.in);

System.out.println("Exoume 400 sokolates,valte ton ari8mo ton sokolaton pou fagate");
fagomenes_sokolates = Keyboard.nextInt();

eminan = 400 - fagomenes_sokolates;
if (fagomenes_sokolates == 200)
{
	System.out.println("Efages tis mises diladi " +fagomenes_sokolates);
}
else if (fagomenes_sokolates > 200)
{
	System.out.println("Efages Parapolles dhladh " +fagomenes_sokolates);
}
else if (fagomenes_sokolates < 200)
{
	System.out.println("Efages liges,mporeis kialles,mono " +fagomenes_sokolates);
}
else if (fagomenes_sokolates > 400)
{
	System.out.println("Egrapses lathos , 400 exoume sinolika pos efages " +fagomenes_sokolates );
}
}
}

 

Alla to teleuteo statement pou lei >400 an grapsw dld 500 dn kanei tpt ...bgazei efages para polles dhladh blabla...gt omos?

Posted

signomi gia to dp ala paratirisa an paw to

else if (fagomenes_sokolates > 400)

{

System.out.println("Egrapses lathos , 400 exoume sinolika pos efages " +fagomenes_sokolates );

}

panw apo to allo me to >200 to bgazei sosta ala meta dn litourgei to 200 :P

Posted

Λογικό...

'Εχοντας τον πρώτο κώδικα, πες ότι η μεταβλητή fagomenes_sokolates έχει την τιμή 500.

Μπαίνουμε στην if

1)Εξετάζει αν η τιμή της μεταβλητής είναι 200. ΨΕΥΔΗΣ

2)Εξετάζει αν η τιμή της μεταβλητής είναι μεγαλύτερη του 200. ΑΛΗΘΗΣ (500>200)

Εδώ σταματάει η εκτέλεση της if, επομένως δεν εκτελέιται η συνθήκη if (fagomenes_sokolates > 400) η οποία θα ήταν αληθής.

 

Μπορείς να κάνεις χρήση διαστημάτων.

Σαν αλγόριθμος(Δεν γνωρίζω την σύνταξη της java):

if ((fagomenes_sokolates >= 0) && (fagomenes_sokolates < 200))

    print "efages liges...";

else if (fagomenes_sokolates == 200)

    print "efages tis mises";

else if ((fagomenes_sokolates > 200) && (fagomenes_sokolates <= 400))

    print "efages para polles sokolates";

else if (fagomenes_sokolates > 400)

    print "Den ginetai na exeis faei panw apo 400 sokolates";

else

    print "Den ginetai na exeis faei arnitiko ari8mo sokolatwn";

 

Posted

Γενικά όταν κάνεις συγκρίσεις, καλό θα ήταν (άμα θες ο κώδικάς σου να δουλεύει σωστά), να ελέγχεις αν η δωθήσα τιμή είναι μεταξύ κάποιων διαστημάτων όπως λέει και ο Hax0r. Μην χρησιμοποιείς απλά >, <, ==, αλλά διαστήματα. Αν το κάνεις έτσι θα δουλέψει όπως το θες.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • I had friends who played on Elegant and I can confirm it wasn't a bad server. I don't know about the AI bots running around, but in my opinion the price is simply too high. I don't think many people will spend that much money on Lineage 2 files when alternatives like L2Scripts already exist.   Of course it's all about personal preference, but for such an old chronicle the price seems ridiculously expensive. Modern chronicles usually offer more value.   Anyway, I wish you the best of luck with the sale. This is just my personal opinion. Whoever likes it, good for them, and whoever doesn't, that's fine too. Everyone has different preferences.
    • https://l2avokado.com/ Hello everyone,   After some time of development, we've decided to open L2Avokado to the public in its current development stage. We're looking for players who enjoy Interlude and would like to help shape the project before its official release.   This isn't a "launch" announcement. Instead, we're inviting the community to log in, explore the server, test the systems we've built, and provide honest feedback. Whether it's bug reports, balance suggestions, progression ideas, or quality-of-life improvements, we'd love to hear them.   Our goal has always been to create an Interlude server that feels familiar while offering a fresh progression experience. We've intentionally avoided custom weapons, armor, and client modifications. Instead, we've focused on redesigning progression through reworked hunting grounds, quests, crafting, and gameplay systems while remaining compatible with a clean Interlude client.   At this stage, the core progression path has been implemented, including the main hunting grounds, quests, custom systems, and events. However, as the project is still under active development, there will inevitably be bugs, balance issues, and areas that require further polishing.   This is exactly why we'd like your help.   We're looking for players who are willing to: Test gameplay and progression. Report bugs and exploits. Suggest balance improvements. Share ideas for new features or quality-of-life changes. Help us build a server that the community genuinely enjoys playing.   The Client and System downloads are already available on our website, so you can jump straight into the game. We're also working on a dedicated launcher that will simplify installation and future updates.   If you're interested in helping develop a unique Interlude project and want your feedback to genuinely influence the direction of the server, we'd love to have you with us.   We look forward to seeing you in-game and hearing your thoughts on Discord. https://l2avokado.com/
    • Mate your server used to play with full of bots, from where you find that revenue? 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..