Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/School-Work / School Work/ancestorPrintingProgram.java |
| Date | Not specified in source |
| Repository | Janady13/School-Work |
| Revision | 4a666c890caf7c43c47d0572dbcc287373c7a78e |
| Branch | main |
| Path or archive member | School Work/ancestorPrintingProgram.java |
| Original SHA-256 | 70bf961d3ca4a47d14549c79a717acd0baadb3e716c45aca3c3e737698023f93 |
| Git blob SHA | bf97f144c169dce9b192b44056a6bbc6c8ffc724 |
| Reading-copy SHA-256 | 70bf961d3ca4a47d14549c79a717acd0baadb3e716c45aca3c3e737698023f93 |
Recovered source transcript
Download complete source text ↓26 lines · 0.8 KB
import java.util.Scanner;
public class AncestorsPrinter {
public static void main (String[] args) {
Scanner scnr = new Scanner(System.in);
final int YEARS_PER_GEN = 20;
int userYear; //Approx. years per generation
int consYear; //User input
int numAnc; //Approx. ancestors in considered year
consYear = 2020;
numAnc = 2;
System.out.println("Enter a past year (neg. for B.C.): ");
userYear = scnr.nextInt();
while(consYear >= userYear){
System.out.println("Ancestors in " + consYear + ": " + numAnc);
numAnc = 2 * numAnc; //Each ancestor has two parents
consYear = consYear - YEARS_PER_GEN; //Go back 1 generation
}
}
}