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

    • ⚔️ L2Origins – Season 1 High Five Classic Welcome to L2Origins, a project built for players who miss the authentic High Five experience while enjoying carefully designed quality-of-life improvements that preserve the original gameplay. Every system has been created with one goal in mind: long-term progression, balanced PvP, and a competitive community. Server Highlights ⚔️ High Five Classic Gameplay 📈 Rates: x5 Adena / x5 Drop & Spoil / x15 Skill EXP 👥 Up to 3 game clients per PC 🏰 Siege & Territory War Rewards ⚔️ Party and Solo Instances 🏆 Advanced Ranking System 🎯 Global Teleport & NPC Buffer 🛡️ Active Anti-Bot Protection 💬 All-In-One Community Board 🎁 Daily Login Rewards 🌎 English Project with an international community. Exclusive L2Origins Systems 🏆 Achievement Skills Unlock permanent passive skills by progressing through: PvP Achievements Olympiad Participation Achievements Every milestone rewards your character with unique passive bonuses, encouraging long-term progression. ⚔️ Faction System Choose one of 7 unique factions, each offering its own permanent bonuses and balanced penalties. 🛡️ The Knights ⚔️ Dark Legion 🔮 Arcane Council 🏹 Hunters Guild 💰 Merchants Union 🗡️ Shadow Assassins 🌿 Guardians of Nature Your choice defines your playstyle and creates a new layer of PvP strategy. 👕 DressMe System Customize your character with classic High Five armor appearances. Each DressMe appearance also grants its own exclusive passive bonuses, allowing players to personalize both their look and combat style. 🏅 Olympiad & PvP Olympiad Participation Rewards PvP Ranking Faction Ranking Event Ranking Arena Ranking Compete against other players and climb multiple leaderboards throughout the season. Why L2Origins? Our philosophy is simple: Preserve the original High Five feeling. Introduce meaningful progression instead of power creep. Keep PvP competitive and rewarding. Deliver unique custom content without losing the Lineage II identity. If you're looking for a fresh High Five server that respects the classic experience while introducing exclusive systems built from the ground up, L2Origins is ready for you. 🌐 Website: https://l2origins.org/ See you on the battlefield!  
    • Well, make it free for everyone to use.
    • Those tools that those guys are selling, you put them in Claude Code and they do everything for you; in fact, I made one exactly like the one this guy is selling.
  • 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..