Don't know if this is in the right section if not please direct me and I will repost in section.

First I want to start off by saying Hi! I'm new to these forums and I'm currently studying computer technologies : System Analyst at Sheridan College Davis Campus.

Currently writing code for class. The following allows users to input 4 marks and it changes the grade to percentage to see the weighting on the following:

Mark 1 Worth 20%
Mark 2 Worth 25%
Mark 3 Worth 20%
Mark 4 Worth 35%

Code is as the following <\code>import java.util.*;

public class GradingSystem {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean valid = true;

// Ask user for input of first lab
System.out.println("Please enter mark for lab1 i.e. 80: ");
double lab1 = input.nextInt();
//Asks user for input of Test mark
System.out.println("Please enter mark for test i.e. 80: ");
double test = input.nextInt();
//Asks user for Assignment marks
System.out.println("Please enter mark for Assignment i.e. 80: ");
double assignment = input.nextInt();
//Asks users for Final Exam mark
System.out.println("Please enter mark for final exam i.e 80: ");
double fexam = input.nextInt();

//Checking to see if mark inputed is valid
if (lab1 < 0 || lab1 > 100) {
valid = false;
}

if (test < 0 || test > 100)
valid = false;
if (assignment < 0 || assignment > 100)
valid = false;
if (fexam < 0 || fexam > 100)
valid = false;

//If False shows message saying Mark is not valid.
if (valid == false)
System.out.println("Mark is not valid.");

//Converting marks to percentages
double lab1p = lab1 * 0.20;
double testp = test * 0.25;
double assignmentp = assignment * 0.20;
double fexamp = fexam * 0.35;

//Calculating what the average is for student.
double averageGrade = (lab1 + test + assignment + fexam ) / 4 ;

// Adding all marks together to divide to get average.
double passOrFailure = (lab1p + testp + assignmentp + fexamp);

//Checks to see if grade is over 49 or equal to
if (passOrFailure <= 49)
System.out.println("You have failed");

if (passOrFailure >= 50)
System.out.println("You have passed!");

//Displaying results to student. If Value is false Value for test is false will display
System.out.println("The total for your Lab #1 is: " + lab1p + "% outta 20%");
System.out.println("The total for your Test is: " + testp + "% outta 25%");
System.out.println("The total for your Assignment is: " + assignmentp + "% outta 20%");
System.out.println("The total for your Final Exam is: " + fexamp + "% outta 35%");
if (valid == false)
System.out.println("Average cannot be computed.");
else
System.out.println("Average is: " + averageGrade);
}
}
</code>

Now the problem I'm getting is I want to take the line
System.out.println("The total for your Lab #1 is: + lab1q + "% outta 20%");

and I want to change it to the following
if (valid == false)
System.out.println("The Mark inputted was not valid, Program will not display mark");
else
System.out.println("The total for your Lab #1 is: + lab1q + "% outta 20%");

But I want to do it for the rest of the code... Would I follow that same aspect... So if a user inputs a WRONG value ( -1 and under or 101+) the Programs outputs that line the mark inputted was not valid.

Please help!