Advertisement
cesarnascimento

loop do while nota 0 a 10

May 30th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. package exercicios;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ex1 {
  6.  
  7.     public static void main(String[] args) {
  8.         int nota;
  9.         Scanner sc = new Scanner(System.in);
  10.        
  11.         boolean notavalida=false;
  12.         System.out.println("Nota: ");
  13.         nota = sc.nextInt();
  14.        
  15.         do{
  16.         if(nota >=0 && nota <=10){
  17.             System.out.println("Digitou: "+nota);
  18.             notavalida = true;
  19.         }else{
  20.             System.out.println("Nota inválida.");
  21.         }
  22.         }while(notavalida=false);
  23.  
  24.     }
  25.     /* César N. */
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement