Click here to Skip to main content
14,331,362 members
   

Java

 
AnswerRe: Halp please? Dice roll game. Pin
Richard MacCutchan6-May-18 21:52
protectorRichard MacCutchan6-May-18 21:52 
QuestionSolving symmetric tree problem by recursive solution Pin
ElenaRez6-May-18 6:52
memberElenaRez6-May-18 6:52 
AnswerRe: Solving symmetric tree problem by recursive solution Pin
Richard MacCutchan6-May-18 21:44
protectorRichard MacCutchan6-May-18 21:44 
QuestionAsk a Question All Questions All Unanswered Mine FAQ I need to compare one file each line with other file all lines which separated by two colon separate .if matches with names I need print matched one in java Pin
Member 138094092-May-18 23:07
memberMember 138094092-May-18 23:07 
AnswerRe: Ask a Question All Questions All Unanswered Mine FAQ I need to compare one file each line with other file all lines which separated by two colon separate .if matches with names I need print matched one in java Pin
Richard MacCutchan3-May-18 0:44
protectorRichard MacCutchan3-May-18 0:44 
QuestionDeep copy of List<> without knowing specific list type Pin
jackbrownii30-Apr-18 10:55
professionaljackbrownii30-Apr-18 10:55 
AnswerRe: Deep copy of List<> without knowing specific list type Pin
Manish K. Agarwal27-May-18 21:32
memberManish K. Agarwal27-May-18 21:32 
QuestionStudent needing assistance while loop Pin
Victor McNeal21-Apr-18 9:15
memberVictor McNeal21-Apr-18 9:15 
I can't seem to figure out what I am doing wrong with my while loop. For some reason it wont execute the loop it just goes on to the next piece of code. please let me know what is wrong with my syntax.

package com.nec;

import java.util.Scanner;

public class Inputs {
	private static Scanner s;
	private static String grade;
	private static Boolean flag;
	private static double averageSum;
	private static int studentCounter;
	private static Double classAverage;

	public static void main(String[] args)
	 {
		grade = "";
		flag = true;
		averageSum = 0;
		studentCounter = 0;
		
		//Inserting While statement to to check for more information
		While (flag); {
			flag = (false); 
		
		s = new Scanner (System.in);
		System.out.print("Enter your name: ");
		String name = s.next();
		System.out.print("Enter scores in three subjects: ");
		int scores1 = s.nextInt();
		int scores2 = s.nextInt();
		int scores3 = s.nextInt();
		double average = (scores1+scores2+scores3) /3.0;
		averageSum = averageSum + average; 
		studentCounter++;
		//System.out.println("\nName: " +name);
		//System.out.println("Average: " +average);
		
		if  (average >= 93) {
			grade = "A";
		}
		if  (average >= 90 && average < 93)  {
			grade = "A-";
		}
		if  (average >= 87 && average < 90) {
			grade = "B+";
		}
		if  (average >= 83 && average < 87) {
			grade = "B";
		}
		if  (average >= 80 && average < 83) {
			grade = "B-";
		}
		if  (average >= 77 && average < 80) {
			grade = "C+";
		}
		if  (average >= 73 && average < 77) {
			grade = "C";
		}
		if  (average >= 70 && average < 73) {
			grade = "C-";
		}
		if  (average >= 67 && average < 70) {
			grade = "D+";
		}
		if  (average >= 63 && average < 67) {
			grade = "D";
		}
		if  (average >= 60 && average < 63) {
			grade = "D-";
		}
		if  (average >= 0 && average < 60) {
			grade = "F";
		}
		
		
			
		
		System.out.println("\nName: " +name);
		System.out.println("Average: " +average);
		System.out.println("grade:" +grade);
		System.out.println("Do you have another set of scores to compute, enter 1 for yes and 0 for no");
			
		int ans2 = s.nextInt();
		//if statement to close the while loop
		if (ans2 == 1) flag = true;
		if (ans2 == 0) flag = false;}
		
		classAverage = averageSum / studentCounter;
		System.out.println("Class Average is:" +classAverage);
			

	}
	
	private static void While(Boolean flag2) {
		// TODO Auto-generated method stub
		
	}

}

AnswerRe: Student needing assistance while loop Pin
Richard MacCutchan21-Apr-18 20:56
protectorRichard MacCutchan21-Apr-18 20:56 
AnswerMessage Closed Pin
9-Sep-19 23:31
memberMember 145858379-Sep-19 23:31 
QuestionJava JUnit test error Pin
CHUCHU YAO20-Apr-18 13:23
memberCHUCHU YAO20-Apr-18 13:23 
AnswerRe: Java JUnit test error Pin
Richard MacCutchan20-Apr-18 20:43
protectorRichard MacCutchan20-Apr-18 20:43 
AnswerRe: Java JUnit test error Pin
jschell21-Apr-18 6:31
memberjschell21-Apr-18 6:31 
GeneralRe: Java JUnit test error Pin
Richard MacCutchan21-Apr-18 20:58
protectorRichard MacCutchan21-Apr-18 20:58 
QuestionJAVA Swing GUI Invoice - problem with correct actionPerformed Pin
Member 1378720218-Apr-18 20:59
memberMember 1378720218-Apr-18 20:59 
QuestionRe: JAVA Swing GUI Invoice - problem with correct actionPerformed Pin
Richard MacCutchan18-Apr-18 21:51
protectorRichard MacCutchan18-Apr-18 21:51 
AnswerRe: JAVA Swing GUI Invoice - problem with correct actionPerformed Pin
Member 1378720219-Apr-18 0:54
memberMember 1378720219-Apr-18 0:54 
GeneralRe: JAVA Swing GUI Invoice - problem with correct actionPerformed Pin
Richard MacCutchan19-Apr-18 1:02
protectorRichard MacCutchan19-Apr-18 1:02 
AnswerRe: JAVA Swing GUI Invoice - problem with correct actionPerformed Pin
snoopy1118-Apr-18 23:17
membersnoopy1118-Apr-18 23:17 
JokeRe: JAVA Swing GUI Invoice - problem with correct actionPerformed Pin
Peter_in_278019-Apr-18 0:39
professionalPeter_in_278019-Apr-18 0:39 
Questiondesign a class Pin
Member 1365742917-Apr-18 21:18
professionalMember 1365742917-Apr-18 21:18 
GeneralRe: design a class Pin
Richard MacCutchan17-Apr-18 22:41
protectorRichard MacCutchan17-Apr-18 22:41 
Questionjdbc connection Pin
Member 137686618-Apr-18 7:26
memberMember 137686618-Apr-18 7:26 
AnswerRe: jdbc connection Pin
Richard MacCutchan8-Apr-18 21:51
protectorRichard MacCutchan8-Apr-18 21:51 
Questioni need help fast.i have only 2 days left Pin
Member 137677117-Apr-18 11:35
memberMember 137677117-Apr-18 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.