Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Convert boolean true and false to pass and fail

$
0
0
Hello, Is there a way I can convert my boolean values from true to "pass" and false to "fail"

Thanks

/*3. Write a program that uses a single array to store your exam marks for six
subjects. Your program should loop through the array and list the results,
indicating the subjects passed, and the subjects failed. Sample output:
Your results are:45 Pass |28 Fail |33 Fail |59 Pass |80 Pass |6 Fail*/

import java.util.Scanner;

public class Q3
{
	public static void main (String[] args)
	{
		Scanner kb = new Scanner(System.in);
		
		int[] arrayMark = {45,28,33,59,80,6};
		
		boolean result = false;
		
		for(int i = 0; i <arrayMark.length; i++)
		{
			
			if (arrayMark[i] == 45){
				result = true;s}
			else if (arrayMark[i] == 59){
				result = true;}
			else if (arrayMark[i] == 80){
				result = true;}
			else{
				result = false;}
								
			System.out.print("Mark " +(i+1) + ":");
			System.out.println(" " + arrayMark[i] + " " + result);
		}
				
		
	
	}
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles