Treceți la conținutul principal


user input Scanner java

// To import an external class you use import
// You can import whole libraries of classes like this import java.util.*;
import java.util.Scanner; 

public class LessonTwo
/* static means that only a class can call for this function to execute
* Creates a new scanner object named userInput
* You create the Scanner object by calling new and passing the Scanner constructor
* the input stream to look at ( = keyboard input)
static Scanner userInput = new Scanner(;

public static void main(String[] args)
System.out.print("Your favorite number: "); // Same as println without a newline

/* The if statement will only execute the code that lies between {} if the value inside () is true
* userInput.hasNextDouble() returns true if the next value entered is a Double
* There are similar methods for the other data types
* hasNextInt() : Integer input
* hasNextFloat() : Float input
* There are others for Boolean, Byte, Long, and Short

if (userInput.hasNextInt())

int numberEnter…
Postări recente

program nr prime pseudocod netestat

int [] nonprime20= {4,6,8,9,10,12,14,15,16,18,20};
int [] prime20={1,2,3,5,7,11,13,17,19};

int isPar(int nr){
  if(nr%2==0){return 1;}
else {return 0;}

int isImpar(int nr){
    if(nr%2!=0){return 0;}
else {return 1;}

int firstRightNr(int nr){
  return nr%10;

int isThisNrPrim(int n){
int  i;
int s= sqrt(n);
//we will verify just the odd numbers except 5
//the even numbers and 5 we have verify all ready before 
for (i=3; i< =s; i+=2){
 if((firstRightNr(nr)==5)&&(i<=s)){ i+=2;}//3 +2 will never be x0
 if(n%i==0) {  return 0; } //nu e prim 
else{ return 1; }//e prim

int howManyDigitsHave(int n){
    int nr = n;
int counter = 0;
counter ++;
return counter;

int singleDigitNumber(int n){
//will never be 11
if(n==11){return -1;} //we just say before 11 is prime
    int howlong = howManyDigitsHave();
    int curentDigit,firstDigit;
firstDigit = n%10;
for(int i = 1;i<=howlong;i++){
curentDigit = n%10;
if( curentDigit!=firstDigit) {return 0;}
return 1;
int isPrim(int nr){


// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile

74111121313417374414124343447 if u know the red part you can generate the orange part
1 0 1 111112222 1 1 23