about 5 years ago
To input the records of students. Display the whole record. Display the name of the youngest and eldest student.
I'm having problem in achieving the third target: If I enter 3 or 5 entries the result is fine but as soon as I enter 5 or 10 entries, the eldest student name shows up but the youngest name does not.
PLEASE HELP ASAP.
After going through your code, i found that inside the "checkage()" function, you have initialized the variables
"eldest" and "youngest" to "age" (i.e whatever be your element at 0th index). And inside both the for loops
you are checking the condition
if(age[i ]> eldest) and if(age[i] < youngest),
these conditions will evaluate to false if your "youngest"
or "eldest" person's age is present at 0th index(age) (Because (a < a) or (a > a) is always false, i.e no integer number can be smaller or greater than itself).Thus "e_name" & "y_name" will never get initialized
in such case. And u won't be able to print there values in this condition.
To overcome this, either you can initialize "e_name" & "y_name" to name initially.
y_name = name;
Or, instead of "<" and ">" you can check for "<=" and ">=" inside the if conditions.
There was one problem in your if condition inside "checkage()" function. You assigned youngest and eldest to a in this case if eldest or oldest be at index 0 then your if condition will return false ( 1 < 1 will return false ) please uncomment your program accordingly as i was testing in linux environment, so i had to comment some lines..
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Terms of Service
| © copyright 2020 FindNerd.com. All rights reserved.
Sign up using