Timtoday's Posts
Nairaland Forum › Timtoday's Profile › Timtoday's Posts
1 2 (of 2 pages)
edicied:Better than the previous java solution, but if all the character is not in the same case, your solution would fail for entry with same character but different cases I.e lower and upper cases which are supposed to count as same. |
What is wrong with your code: 1. Check how you are using the function scanf(...) remove the newline "\n"you are using. scanf is not the same as printf, though they might be similar. 2. Why is your average though declared to be float has integer division? Integer division doesn't given you float "results". With integer division the "decimal" part is truncated. So you might have to cast one of the operand of the integer division as float to get what you want. Of course, you will get your answer as "float" with decimal places and ZEROs without casting. But that would not be the right answer. What you don't NEED. Throw out the header #include <stdlib.h>because you don't need it here and it will make your file unnecessarily large. Why is that? I will allow you to search that out. My point, use only what you need. Lastly, format your code properly using spacing. It makes your code easy to read. Of course, I could have just corrected your code and repost. But I would not have helped you and but now that you have to make the changes yourself. When you get it I would not have robbed you of the joy of accomplishment. Hope this helps. |
seunthomas:I don't expect you to! Please just don't call me up on ridiculous post like this! |
seunthomas:Good morning everyone. @seunthomas, Please you probably should not have brought me up into this. I saw your post, though I went through it there was no need making a comments. Why? Because it is obvious you are living in your own reality with alot of false claims. But since you called me up by name, I will yet help you see clearly that you don't know what you claim you know. Secondly, am responding because I felt you think that those who post more are likely to be right or correct. Multiplying words on falsehood doesn't make such claims correct and the loudest person in the room is not the usually the correct ones! So, let me try one more time and see if you will get it. @larisoft, mentioned to you that your code "WORKED" because by making your objects extend one parent object,Your response:
My Comments: If anyone runs that code of yours but have no idea what his going on such will immediately conclude like you, that your answer to @FincoApps was TOTALLY right when you said They are actually not of type object rather the primitive types are upcasted to their prevalent java.lang type.But of course, with a little pain of code, the obvious is revealed! How? Instead of using this
like you did, do this
Maybe then you will get what I have explained to you in the previous post and what others are now telling you. They are all ACTUALLY a type of Object class. ARRAY in Java has a single TYPE! Secondly, you also said this There is actually a class Array which is an extension of the primitive type [] and that can be extended.Array "class" by design take the type they "refer" and as such are instances of such type and "sir" you can't extended, of course nothing is impossible. Maybe you want to extend Java itself! Array are not like conventional classes! Get that sir? And I don't think you can extend class java.util.Arrays. Please NOTE the "S". Still on this your assertion: They are actually not of type object rather the primitive types are upcasted to their prevalent java.lang type.ABBA Oga sir?! The primitive types, you gave in your code are NOT just UPCASTED! They were autoboxED in other words wrapped if you will into their reprepective Wrapper Classes, which in turn are autoupcast into their MOTHER (or super if you will) class. That is why I have use the methods getSuperclass twice to make you see it! But if you had used instanceof like I told you in the previous post maybe you would have "healed" of this confusion! I don't expect you to anyway! Now to the part where you called me up! You are actually right and wrong at the same time. In my array at compilation time, i am putting in primitive types which are all@larisoft was right and wrong at the same time? But you didn't tell where he was wrong and where he was right! You are only trying to play safe! More so, the reason why your code works was NOT because "everything is an object in java", Please stop saying that it make you look ____. I can't say it because am 2 yrs old remember? A lang with primitive types, that needed a wrapper class of it's type wouldn't be such where "everything is an object"! Oh! because the compilers didn't scream out with errors makes you believe "everything is an object in java"? If only, you have been writing Java since "Odun gbogboro" like you said, you should have know that before Java 1.5 i.e Java5, the compiler would have handed you errors, but thanks to autoboxing and her cousins! Moreso, in plain text, (and if you will always tell layman the absolute truth, cos they will find out with time!). Which makes this statement But in plain text and for a layman, our array is taking different types but the JVM is converting it into javaof yours NOT TRUE! What you called "conversion" doesn't happen EXPECT under some conditions, which is not part of your last quote. You might have to go check that out! Am sure you will tell me you have read it all! Which is obvious you have not! Try get the class name of "x" as you have it and check it's super class, then input primitive type int into the array and try to dereference it like we did with the Object array previously! Seriously, it would do you good to REALLY know what you are taking about! Or if you are Satisfied with where you are please just stay in the thread where all you do is chest-beating and abuses. And if you must come up with some study answering questions please just DON'T bring me in! No, i don't hate you, in fact, you make me laugh hard with several of your "funny" assertion. But I hate to stay up hitting the same point for several post! |
FrankLampard:Or you might help him get that from Ojuelegba. It might be a bit costly at CSM, my opinion though based on my experience the last time I was in Lagos in August. |
seunthomas:@lekropasky Please don't just disturb yourself over this guy. It is obvious he knows nothing! He was finding it difficult to understand simple concepts in Java, yet he boast of writing his own JVM in 2006! Yet he didn't know that EVERY CLASS in Java EXTENDS the "class" Object EXCEPT Object itself.. Which will make ANY instance of ANY CLASS, a TYPE of "Class" Object. Which still SHOUT to the ignorance of the Methuselah programmer that an ARRAY in Java takes only a SINGLE TYPE! Please note, I didn't say TYPES our Methuselah programmer did! Methuselah programmer, Sir, Why change to the statement below? which is an array of objects and holds different types of objectBut you initially said those were PRIMITIVES TYPES! So now they are different types of object? So, I have educated you now a bit, but shame will not allow you to be humble. Let me still help your arrogant ignorance a bit more. Remove the word "different" here they are all TYPE of Object,, all you need to do to know this is, just use instanceof to do a test and you will be healed totally! Hope you know how to use that?! Let me not take the trick here is how if (s[0] instanceof Object) System.out.println("It is an Object!"Lastly, I dare you @seunthomas To quote the very first sentence of this Oracle Java Tutorial https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html and prove me wrong! But if you will not, please don't reply me! I know you will and further show how empty you are on Java! Selah! |
seunthomas:Documentation are made for humans. Please read it. It will help you to stop making yourself a laughing stock on this thread. I pointed you to one, not to stackoverflow, but your arrogance will not allow you to go check. Am sure you didn't know what the method getClass() returns that is why you are saying ..Class and Objects are different..as if you are raising a revelation. Go educate yourself properly with the tools, you claim you know. And stop showing us that you have wasted 3 yrs of your life learning nothing! Than cut and paste! |
seunthomas:You see, you really have low self-esteem. Age has got nothing to do with showing you that. Am actually 2 yrs old, here you are struggling with a 2yr old. It is not winning an argument. That is your area of specialization. By the way you are all wrong. Class and Objects are different.But you should have shown me HOW naw, clearly defining what both are. But as usual, you must change the point of discussion, since it is obvious you don't know what you are talking about. For your information, an "object" "of a class" is an instance of that class. Am sure I have made mention of that again and again. Using the word "instance" But in your mind, one who had shown you times and again that he knows what is talking about DOES NOT KNOW THE DIFFERENCE! Obviously you live in your own reality! That is why you will claim "Everything in Java is an OBJECT!" Remember am 2 yrs Old. Please take your own advise and probably go sleep with it. I hope youMethuselah wont go outside and do this.! |
seunthomas:I have told you, leave those your self praise singing to those it will catch.. Am not in that league! If you have to pat your ego in a public forum, you problem have a low self-esteem. I will help one more time maybe you can see clearly and more especially for those who may want to follow your wrong side of the books, which only God knows where they are from.
I don't need to tell you am right. My points and posts justify itself... Just make sure you read the link on array I linked to in one of my post and stop telling yourself you know, then it is obvious you know NOTHING! Good Morning! |
seunthomas:You are the one that don't know yet you are shouting everywhere! I know you will jump the gun! I just caught you using your own code! I just don't write codes, I understand what I write unlike you, who believe everything is an object in Java! I have demonstrated to you every time you raise a point that I know what is happening under the hood! Not just talk, talk... Please next time. Read well before you answer questions. Arrays in Java holds a fixed number of values of a single type. It can't be more clearer. Every other object which extends an Object is an Object! It is still a single type! Can that be so difficult? And it is not a primitive datatype. Which is one of the thing makes everything in Java NOT to be an Object. The other is it has static types. Awosh!!!! |
seunthomas:I should admit am wrong? When you don't even know what you are saying? Holding primitives indeed!!! Bro, you don't know these things! Just go and sleep! Google can help you. Just ask is everything in Java an Object?! |
seunthomas:Like I mentioned, you might know some other language NOT Java. Because if you know Java and how JVM works, you will not that what you have in the are not "primitive" types. It is has been converted to the Wrapper Class Type of the primitive type I mentioned to you. In fact, using a String should have prompted you to know that. Because String is not a PRIMITIVE TYPE, and She is immutable. At anytime you call String name = "My Name"; What you are doing REALLY is String name = new String("My Name".Let me give you a taste of it using your own code do this:
You see yourself? |
seunthomas:Ahhhhaaa.. multiples of what types? Every Object defined in Java extends the "Mother" object called "Object". Which means that every class is a sub-class of the super class Object. And as far back as 10.19pm last night. I mentioned to you that ..Storing different sub-classes of a super-class in the ARRAY of that super-class is not the same as storing different objects of DIFFERENT types like you have in Perl, JavaScript and the likes...So what point are you making? In fact, in that same post of 10.19pm I said this If you inherit from a class say Employee, with a subclass say HourlyEmployee. The best you can have stored in the ARRAY instant object of Employee is HourlyEmployee, you can't store into it a class TYPE of class say Student. And that is if you can even instantiate Employee to start with, that is if Employee is not an abstract class or an interface.Of what difference is what I said and what you are bringing up now? Some 2 hrs afterwards? Common!! |
seunthomas:The high-lighted words of yours is WRONG!! And I have shown that even in my first post! seunthomas:Go back and read what I posted as far back as 10.19pm. You have not said anything new! Stop playing on words. seunthomas:Beautiful, you mentioned that you "THINK"! Well let me help you see properly so that you will get it that you are the one confused not me! Check here https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html it will clear up your confusion. The documentation first sentence shows who is confused here .. "..An array is a container object that holds a fixed number of values of a single type" Read the rest yourself... You may know some other language, but java I doubt it! Maybe not as well as you think you do. |
seunthomas:You don't get it, do you? I really don't care the YEARS you used in learning the concept of OO. On the ARRAY stuff in Java, bros you miss am! Go back and check what I wrote, I know the OOP is not specific to a lang., However, i have been specific in this thread since what we are taking about is Java, a lang, that implement OOP. Need more help? From whom? If with all the experience you often claim you don't know that ARRAY in Java are of single type. I think you need to come down from your high horse of self-importance, and take a second look at yourself and everything around you. You think more highly of yourself, than you really worth! Contact you?! So that you will tell me that "everything in Java is an Object"? Over-the-bar! As for both Bruce Eckel's Books, I have them. In fact, I can give you the third one, which is Thinking in C++, Volume 2. I bet you don't know there are two volumes to that book! So, thanks. No thanks. I think I have to say good-nite... I better be watching a movie than having this discussion. |
seunthomas:Whoever taught that need go check his or her book again! Am sure, you read my last post and why everything in Java is not an object! Except Ruby is now the NEW Java! Every OOP language "implements" the OO ideals to varying degrees. If the assertion is true that all OOP lang has everything as Object, then the statement will be true that "In Cpp everything is an object"!!! I laugh in Bangladeshi! |
seunthomas:I don't need to do any research, I gave you examples of what am saying. Maybe you need to do more research as everything in Java is NOT an OBJECT. Java is not Ruby! Please don't get it confused. Every primitive type has what is called a Wrapper Class Type which is an Object. Though these can take the primitive datatype but it does mean that the primitive datatype in Java is an Object. More so, there is a class called Arrays, from java.util.Arrays. Used to make working with arrays of different datatypes a bit easier. That also doesn't make an ARRAY of a TYPE a datatype in itself. So what other research, do you think you will like to recommend? In Java, an ARRAY of a type holds a single type! Plain and simple! Please don't complicate things. |
seunthomas:Am sure you know that array is not a TYPE in itself. If you inherit from a class say Employee, with a subclass say HourlyEmployee. The best you can have stored in the ARRAY instant object of Employee is HourlyEmployee, you can't store into it a class TYPE of class say Student. And that is if you can even instantiate Employee to start with, that is if Employee is not an abstract class or an interface. In the same vein, you can't store Strings in the ARRAY of TYPE Integers or Doubles... It doesn't work in JAVA that way, like I said in my previous post. Storing different sub-classes of a super-class in the ARRAY of that super-class is not the same as storing different objects of DIFFERENT types like you have in Perl, JavaScript and the likes. Except you would like to show that all datatypes are the same as regards "vanilla" ARRAYs. One of the reasons for other "containers" like we have it C lang., and her cousins like Cpp, Java and the likes. |
silento:You are right. The beauty of all these is that Java took C lang., to another level by even making it alot easier to use enum. Compare this: Code in C lang.
Note that it is the programmers responsibility, to take care of the "one-off" since, array and enum in C, will start from 0. Same in Java, but it is all take care off. Code in JAVA
|
elfico:In Java, the likes of ArrayList<type>() also holds multiple types unlike the "vanilla" or plain array, which of course is the first data structure programmers are introduced to in so many programming languages. |
seunthomas:I disagree in this sense ... A "vanilla" array will store the same type in JAVA and a few of her cousins like C and C++. E.g
Even if you write a class and make an array of it. Though the object of that class consist of various datatypes, you will still only be able to store the "type" of that class in it's array, even if you make a subclass of it. E.g
It is quite different to what one can do in languages like Perl, Python and some others. Just saying... |
stack1:Hello, Take your time.. On the upgraded program I think it works better now.. And like I mentioned previously, one can also do this:
The above should also work as intended.. So, enjoy yourself... later bro... |
stack1:Stack1, Well done. I see your comments. Like I said we would be using all manner of "Brute force" solutions handpicking char, instead of token solution. We could even give a solution without using either bool datatype or an array like you are using. But it will be many "key-stoke" solution. More over, I saw that you have "stylishly" updated the comments having /**** UNIX/LINUX ***/ But I have not tested the modified code to see if it works...Nice work bro, I will check back later... got to sleep! |
stack1:Hi sir, I came to read gossips on NL and it happened that I came across your post again... So I said let me learn small. Below is my finding after testing the program you gave. If you test the program above with itself, ALL of the comments will be removed EXPECT this line system("clear" ); INUX */So, that means a RED flag was raised and the program it is not working as we wanted. So, just as you asked I pulled in a lot of comments to see how the program will do. Like this below
Then the program tested again, and it failed badly! So, I adjusted it a bit. Since the program is failing on removing multiple comments, therefore I focused on that. Below is the rewrite if you will:
Then tested the program against itself and I had what we wanted! I would rather have preferred reading a whole line at a time then parse it, than hand-picking char like we are doing... I understand that since you have not explain File I/O in C, that maybe difficult for the readers to use. since we must be tested on what we have discussed do far. That is good. But I believe parsing is a lot easier using chunks instead. Nice one bros.... Keep Up the great work... |
stack1:While the issues of ASCII value and others in my previous post still apply to this. I will like to draw your attention to this #define PI = 3.142....Contrary to this statement so anywhere you use PI, the value 3.142 would be substituted. No your program will NOT compile! WHY? an expression is needed before the token "=". In fact, the substitute value of PI is seen from the space that follows afterwards... Probably is a typo! You are doing great boss... |
stack1:Hi Stack, Let me first say nice work. It is not easy to put up tutorials and as such in C programming language. The language of the gods! Lol.. I know plenty talk go start from here now! All the same, there are one or two things in my opinion that i felt is NOT sitting well as regard some of the examples you posted. At least, from this one and those that followed. Of course, there are "some-what" in the previous ones like using a char datatype to get the return value of "macro" getchar which obviously returns an integer. Of course it works because intrinsically char are "integer". And you indeed use a correct return afterwards. That been said, checking your example above, it will only take care of "spaces" whose ASCII value is 32. "Space-like" tab and others will NOT be taken care of. Secondly, using a "raw" value i.e the ASCII value will defeat clarity of codes. Yes, you commented the line, but plain integer 32 could also be used for other things IF the code is extended or for other reasons. Somehow or somewhere portability will be defeated. More so, why must I cram or have to lookup ASCII values to be able to write codes? It will further drive potential C programmer's away. Lastly, there are other difficult concepts in C already why add this to it. It is like trying to know the IP address of google instead of just using www.google.com. What do I think? Since, C, already gave us a header file <ctype.h>Let us use that to our advantage and write a more portable codes, instead of "hand-picking" values. Using such header, allows us to test more conveniently the value we are getting from standard input or file, however the case maybe. Below is rewrite of some sort...
Really, there is (might be) NO *need* for the self defined macro included but to show that allowing the language to do it work. It a lot painless some of the time. Just a note. |
vim |
nnamdiosu:Sorry to say, your illustration is faulty. Why? If your phone battery is dead or your phone is dead means it has stopped to work, then you transpose that to mean that you ask an "evil spirit(s)" as the case may be, to die means to stop it activities in your life. What you are saying is that a child of God could have a demon in his/her lives, but the spirit will have no power to perform their enterprises, just like dead battery. Because, though your battery may be dead but still remain in it place until recharged again. Mean while, what the scripture required us to do is to CAST out devils! Not ask that they lose their powers, while we endure their presence. We are to tread on serpents and scorpions, and over all the power of the enemy. Secondly, why the battery illustration is not accurate, can the devil lose his power like a battery will lose it's charge due to usage? if so, where does he(they) refuel or recharge? Go and check in scriptures, the person through whom they operate might cease to do what they are capable of after the spirit is cast out, but the spirit itself doesn't. That is one of the reason, I know that all of the fall down and die prayers are aimed at people and not spirits, because spirits don't die to start it. Example, a so called Pastor recently prayed that El-rufai will fall down and die if he don't reverse a policy, am sure he is also talking to a spirit called El-rufai shea? He even boasted that he prophesied that Audu of Kogi State will die, and so it happened. What a pity! Please go and read your bible, the judgement of those outside the church is not in our hands. We are sons of God NOT God! Lastly, if you are a child of God and you still have a compartment for the devil to ocuppy, like a phone will for a battery, then it is your fault! Why? scriptures says "...Neither give place to the devil..." -- Eph 4:27. Read that passage in context. A pastor said long ago and I agree with him, that one of the problem of the church today is biblical illiteracy. For example, who is the fire met for? The Holy "Ghost" fire is for what? To burn the devil? If so, why didn't Jesus or his disciples use it? Is Jesus not the one to baptized US with the holy spirit and fire? Simple cast the devil out! And stop devil worship by giving him all the attention. God is no equal with Satan. |
Johniyk2:That programming is step by step doesn't state the language people start with. You can still learn step by step using any programming language of your choice. The only difference is the learning curves. Everybody doesn't have to start with HTML, especially when one is not majoring in web designs. In fact, starting with those languages that people "believed" to be difficult even gives a better perspective for others "supposedly" easy ones. Which for me is the way to go. Often times the difficulties is in the saying of many. |
1 2 (of 2 pages)
;
But I have not tested the modified code to see if it works...
You are doing great boss...