Program 1

Use the checklist to mark the code below. Ask your instructor if you need to use this sheet as an answer sheet to complete other questions in the lab assignment.

import java.util.*;
public class WhileEx
  public static void main(String[] args)
    Scanner console = new Scanner(;
    int age;
    int total = 0;

    System.out.println("Please enter 10 ages: ");
    for (int i = 0;i < 10; i++)
      age = console.nextInt();
      total = total + age;
    System.out.println("average age is " + (float)total/10);

Security Checklist

Vulnerability: Failure to Validate Input Course: CS1
Check each line of code
1. Mark with a V each variable that is input
For each V, which of the following is applicable
1. Check length?
2. Check range (reasonableness)?
3. Check format?
4. Check type?
Highlighted areas indicate vulnerabilities!
Copyright © Towson University