My Code Files
← Back to Home
1year.c
/* Paste your 1year.c code here */
#include
#include
#include
#include
#include
// private types -----------------
// NodeObj
typedef struct bibleBook{
char* name;
int chapters;
struct bibleBook* next;
} bibleBook;
// Node //Book
// Defines The 'nodeObj' or bibleBook
// to be Book so we dont have to type
// struct bibleBook all the time
typedef bibleBook* Book;
// newNode()
// constructor of the Node type
Book newBook(char* name, int chapters) {
Book N = malloc(sizeof(bibleBook));
assert(N!=NULL);
N->name = name;
N->chapters = chapters;
N->next = NULL;
return(N);
}
typedef struct BibleObj{
Book head;
int numItems;
}BibleObj;
//Bible
// defines BibleObj to be BibleObj
// So that we dont have to type
// struct all the time
typedef struct BibleObj* Bible;
Bible newBible(void){
Bible B = malloc(sizeof(BibleObj));
assert(B != NULL);
B->head = NULL;
B->numItems = 0;
return B;
}
// n for name
// c for chapter
void insert(Bible B, char* n,int c){
if(B->numItems == 0){
Book Bib = newBook(n,c);
Bib->next = B->head;
B->head = Bib;
}else{
Book Bib = newBook(n,c);
Book position = B->head;
while(position->next != NULL){
position = position -> next;
}
position->next = Bib;
}
B->numItems++;
}
void printBible(Bible B){
Book Bib = B->head;
while(Bib != NULL){
printf("Book %s has %d Chapters\n",Bib->name,Bib->chapters);
Bib = Bib->next;
}
}
//Bible B is the book that you are reading
//deadline is the days you have to read the book
//pace is the chapters you are reading per day
void readDaily(Bible B,int deadline,int pace){
int temp = 0;
// Chapters to read today
int ctrt = 1;
// Chapters to read today after
int ctrta = 1;
Book Bib = B->head;
int concatIndex;
char * add = malloc(20*sizeof(char));
char dash ;
// Loops through the days of the year
for(int i = 1; i <= deadline; i++){
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
//Make sure to exit the loop if the Bible or book's next is NULL
}
if(Bib->chapters == 1){
ctrta --;
// dont increase chapters to read after on books with only 1 chapter
}
if(i <= 31){
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("January %d - read chapters %d-%d of %s%c%s
\n",i,ctrt,ctrta,add,dash,Bib->name);
add = "";
dash = '\0';
ctrt = ctrta;
}
if(i > 31 && i <= 59){
temp = i;
temp -= 31;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("February %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
add = "";
dash = '\0';
ctrt = ctrta;
}
if(i > 59 && i <= 90){
temp = i;
temp -= 59;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("March %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 90 && i <= 120){
temp = i;
temp -= 90;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("April %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 121 && i <= 152){
temp = i;
temp -= 121;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("May %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 152 && i <= 182){
temp = i;
temp -= 152;
if(i >163 ){
for(int j = 0; j < 7;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}else {
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}
printf("June %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 181 && i <= 212){
temp = i;
temp -= 181;
if(i < 185){
for(int j = 0; j < 7;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}else{
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}
printf("July %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 212 && i <= 243){
temp = i;
temp -= 212;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("August %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 243 && i <= 273){
temp = i;
temp -= 243;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("September %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 273 && i <= 304){
temp = i;
temp -= 273;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("October %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 304 && i <= 334){
temp = i;
temp -= 304;
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
printf("November %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
if(i > 334 && i <= 365){
temp = i;
temp -= 334;
if(i >356 && i <= 361){
for(int j = 0; j < 4;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}else{
for(int j = 0; j < pace;j++){
Bib->chapters -= 1;
ctrta++;
if(Bib->chapters == 0){
add = Bib->name;
dash = '-';
if(Bib->next == NULL && Bib->chapters == 0){
ctrta --;
break;
}else {
Bib = Bib->next;
ctrta = 1;
}
}
}
}
printf("December %d - read chapters %d-%d of %s%c%s
\n",temp,ctrt,ctrta,add,dash,Bib->name);
ctrt = ctrta;
add = "";
dash = '\0';
}
}
}
int main(){
char * books[] = {"Genesis","Exodus","Leviticus","Numbers","Deuteronomy","Joshua",
"Judges", "Ruth","1 Samuel","2 Samuel","1 Kings","2 Kings","1 Chronicles",
"2 Chronicles","Ezra","Nehemiah","Esther","Job","Psalm","Proverbs",
"Ecclesiates","Song of Solomon","Isaiah","Jeremiah","Lamentations",
"Ezekiel","Daniel","Hosea","Joel","Amos","Obadiah","Jonah","Micah",
"Nahum","Habakkuk","Zephaniah","Haggai","Zechariah","Malachi","Matthew",
"Mark", "Luke","John","Acts","Romans","1 Corinthians","2 Corinthians",
"Galatians","Ephesians","Philipians","Colossians","1 Thessalonians",
"2 Thessalonians","1 Timothy","2 Timothy","Titus","Philemon","Hebrews",
"James","1 Peter","2 Peter","1 John","2 John","3 John","Jude","Revelation"
};
int chaptersPerBook [] = {50,40,27,36,34,24,21,4,31,24,22,25,29,36,10,13,10,42,150,
31,12,8,66,52,5,48,12,14,3,9,1,4,7,3,3,3,2,14,4,28,16,24,
21,28,16,16,13,6,6,4,4,5,3,6,4,3,1,13,5,5,3,5,1,1,1,22};
printf("You will be reading about 3 chapters per day
\n");
Bible oneYear = newBible();
for(int i = 0; i < 66; i ++){
insert(oneYear,books[i],chaptersPerBook[i]);
}
readDaily(oneYear,365,3);
/*
//printf("You will be reading about 7 chapters per day
\n");
Bible sixMonths = newBible();
for(int i = 0; i < 66; i ++)
{
insert(sixMonths,books[i],chaptersPerBook[i]);
}
//readDaily(sixMonths,180,7);
//printf("You will be reading about 14 chapters per day
\n");
Bible threeMonths = newBible();
for(int i = 0; i < 66; i ++)
{
insert(threeMonths,books[i],chaptersPerBook[i]);
}
//readDaily(threeMonths,90,14);
*/
return EXIT_SUCCESS;
}
README.md
/* Paste your README.md content here */
# My Project
# 📖 Bible Reading Plan Generator
This is a C project that generates a one-year Bible reading plan using linked lists. The program outputs a structured schedule to the terminal and saves it to a text file. The output is also displayed via a GitHub Pages site with simple HTML and CSS.
> 💡 This project was built with help from Large Language Models (LLMs), including ChatGPT, to assist with code, Git workflows, and website setup.
---
## 🔧 How to Run the Program (Windows)
### 🧰 Requirements:
- A C compiler like **GCC** (MinGW recommended for Windows).
- Command Prompt access.
### 🛠 Instructions:
1. Open Command Prompt and navigate to the project directory:
```cmd
cd C:\Users\charles\ucscGit\Reading-Plan-Linked-Lists
2.Compile the program using GCC:
gcc 1year.c -o ReadingPlan.exe
3.Run the program:
ReadingPlan.exe
4.The program will:
Print the reading plan to the terminal.
This is my reading plan linked lists project.