The Artima Developer Community
Sponsored Link

Java Answers Forum
pls help by giving some clues

1 reply on 1 page. Most recent reply: Mar 9, 2003 7:16 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Ling

Posts: 13
Nickname: ling
Registered: Feb, 2003

pls help by giving some clues Posted: Mar 9, 2003 3:59 AM
Reply to this message Reply
Advertisement
Hi, i am working on an assignment which is briefly described below. Can any kind souls just give me some clues on how to create the java program for it? I do not expect the full answers cos i hope to attempt it myself so giving clues to help me start out is greatly appreciated...thanx!


Simulation - A virtual student taking test. A virtual student takes a test that has 8 true/false questions, and the probabilities of his/her answering the questions right are: 41%, 36%, 65%, 33%, 67%, 53%, 38%, 61%, respectively. All questions should be answered. If any question is answered wrongly, 20 marks are deducted, until the final score reaches 0.
Write a program to simulate the performance of such a virtual student. A sample run of the program looks like:

C:\>java program
FTTTTTFF
Score (out of 100): 40

C:\>java program
TTTTTTFT
Score (out of 100): 80

C:\>java program
FFTFFTFF
Score (out of 100): 0


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: pls help by giving some clues Posted: Mar 9, 2003 7:16 AM
Reply to this message Reply
Your program shell should go something like this:


public class TestSimulation{

private String testAnswerString = "";
private String correctAnswerString = "TFTFTFTF"; // change this to the correct sequence

public static void main(String[] args){
if (args.length == 1){
TestSimulation simulation = new TestSimulation();
simulation.testAnswerString = args[0];
String scoreString = simulation.processAnswerString(simulation.testAnswerString);
System.out.println(scoreString);
}else{
System.out.println("Useage: java TestSimulation testAnswerString);
System.out.println("Example: java TestSimulation FTTTTTFF);
}

}

public String processAnswerString(String testAnswerString){
String scoreString = "";
int score = 100;
//** your code goes here *//
// initialize score
// process each character of testAnswerString
// with correctAnswerString in a for loop
// update score with each pass
// update scoreString at the end
return scoreString;
}
}

Flat View: This topic has 1 reply on 1 page
Topic: Issue using java.io.File Previous Topic   Next Topic Topic: SNMP Application using java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use