Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Fudge"
given-names: "Michael"
orcid: "https://orcid.org/0009-0006-2760-9360"
title: "LearnJava: Code samples and exercises for learning Java"
version: v3.0.0
doi: 10.5281/zenodo.10607299
date-released: 2014-07-30
url: "https://github.com/mafudge/LearnJava"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* the area and perimeter of the recrangle.
*
* Area = Length x Width
* Perimeter 2 x Length x Width
* Perimeter = 2 x (Length + Width)
*
* SAMPLE RUN:
* Enter Length: 7
Expand All @@ -24,7 +24,7 @@ public class AreaAndPerimeterOfARectangle {
public static void main(String[] args) {
// declare variables

// get length and with inputs
// get length and width with inputs

// perform area, perimeter calculations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.print("Enter degrees for angle 1 : ");
a1 = input.nextInt();
System.out.print("Enter degrees for angle 3 : ");
System.out.print("Enter degrees for angle 2 : ");
a2 = input.nextInt();
System.out.print("Enter degrees for angle 3 : ");
a3 = input.nextInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,32 +57,12 @@ SAMPLE RUN (three invalid attempts)
public class ATM {

public static void main(String[] args) {
//TODO: Write your code here.
System.out.printf("*********************************\n");
System.out.printf("*** Welcome to FudgeBank ATM! ***\n");
System.out.printf("*********************************\n\n");
Scanner input = new Scanner(System.in);
BankAccount myacct = new BankAccount("1234", 500);
int attempts = 0;
boolean success= false;
while(true) {
System.out.print("Enter PIN # ==> ");
String pin = input.nextLine();
attempts++;
if (pin.equals(myacct.Pin())) {
success = true;
break;
}
if (attempts >= 3) {
success = false;
break;
}
}
if (success) {
menu();
} else {
System.out.println("You entered an invalid pin 3 times!");
}
//TODO: Write your code here.

}

public static void menu() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,28 @@ public static void main(String[] args) {
System.out.printf("*********************************\n\n");
Scanner input = new Scanner(System.in);
//TODO: Write your code here.

BankAccount myacct = new BankAccount("1234", 500);
int attempts = 0;
boolean success= false;
while(true) {
System.out.print("Enter PIN # ==> ");
String pin = input.nextLine();
attempts++;
if (pin.equals(myacct.Pin())) {
success = true;
break;
}
if (attempts >= 3) {
success = false;
break;
}
}
if (success) {
menu();
} else {
System.out.println("You entered an invalid pin 3 times!");
}

}

/** main menu of ATM */
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# LearnJava

[![DOI](https://zenodo.org/badge/11675734.svg)](https://zenodo.org/doi/10.5281/zenodo.10607299)


This repository contains code samples and exercises to support the **Learn to Program in Java** video series.

[Here's a link to the series on YouTube](https://www.youtube.com/playlist?list=PLyRiRUsTyUXhUXoOPEdMZWhGpGeSQFZgH)
Expand Down