(java Only) A Programming Challange. - Programming (2) - Nairaland
Nairaland Forum › Science/Technology › Programming › (java Only) A Programming Challange. (2699 Views)
| Re: (java Only) A Programming Challange. by sparko1(m): 9:46am On Oct 22, 2013 |
CHARLYX9: You just gat me cracking up which good programmer r u insinuating on that are on nairaland if not only 'hello world' whch they managed to know whatelse.lolFor one you need life purpose, and why do you think they need to defend themselve by jumping at the post, i for one just started java about two weeks ago and i can tell you with what i now know i can try this out and why are so keen in proving there are no good programmer on nairaland? Just for the record i have seen what stuf these guys are made of and most of them have a different field of study. So please try using your head and hand when typing. |
| Re: (java Only) A Programming Challange. by omoelu1(m): 1:49pm On Oct 30, 2013*. Modified: 6:49pm On Oct 30, 2013 |
This is my solution, I dont know if it solves the question but am sure its corrects and runs properly. PS: Forgive me cos i didnt comment d code: import java.util.Scanner; public class Result { int passes = 0; int fail = 0; int counter = 1; public void displayMessage( ) { System.out.println("Welcome to the Result overview" ;} public void enterGrades(){ while(counter <= 10){ System.out.println("Enter result: " ) ; Scanner input = new Scanner(System.in. ) ; int result = input.nextInt( ) ; counter ++; if(result == 1 ) { passes = passes+1; } else if(result == 2 ) { fail = fail + 1; } } System.out.println(passes + " passed, while " + fail + " failed" ); if(passes > 8 ) { System.out.println("Bonus to instructor" ) ; } } } |
| Re: (java Only) A Programming Challange. by dsypha(op): 6:14am On Oct 31, 2013 |
pls a moderator help me close this thread!!! |
| Re: (java Only) A Programming Challange. by Daarsenic: 3:41pm On Oct 31, 2013 |
/*AIM: 1. Input each test result (I.e , a 1 or a 2). Display the message "Enter result" on the screen each time the program requests another test result. 2. Count the number of each test types. 3. Display a summary of the test results, indicating the number of students who passed and the number who failed. 4. If more than eight students passed the exam, print the message "Bonus to instructor". METHOD: java.scanner : to get user input looping: for loop conditioning: if statement method(s): main and grading method */ package grader; import java.util.Scanner; public class Grader { public static void Grading(int p,int f,int t){ Scanner get_input = new Scanner(System.in); int counter = t; int pass = p; int fail = f; int grade; for (int i=1 ; i <=counter; i++){ System.out.println("Student "+i+" Enter grade(pass =1 or fail=2) = " ;grade =get_input.nextInt(); if(grade == 1 ){ pass += 1; }else if(grade == 2 ){ fail += 1; } } System.out.println(); System.out.println("SUMMARY" ; System.out.println("TOTAL NUMBER OF PASS(ES) = "+pass); System.out.println("TOTAL NUMBER OF FAIL(S) = "+fail); System.out.println(); if(pass > {System.out.println("REMARK: "+"BONUS TO INSTRUCTOR" ; } } public static void main(String[] args) { int no_of_pass = 0; int no_of_fail = 0; int total_no_student = 10; Scanner get_from_user = new Scanner(System.in); int test = 0; Grading(no_of_pass,no_of_fail,total_no_student); } } |
| Re: (java Only) A Programming Challange. by Daarsenic: 3:43pm On Oct 31, 2013 |
Daarsenic: /*AIM:Run Correctly |
How To Choose A Programming Language • What U Need To Know Before Learn A Programming Language • 2 • 3 • 4
Node.js Vs Php • A Beginner’s Guide To Web Development • How can a user recover BKF file?
;
{