// CSIS 2610L: Final Exam Lab
// DUE: Friday, May 1st 2026, 11:59pm

// ===== L1: Bizarro World (30 pts.) =====

// In Bizarro World, all the letters of the alphabet correspond with the 
// Latin symbols in reverse order.
// E.g., our 'a' = their 'z', our 'b' = their 'y', etc., and their 'z' = our 'a'.
// The same applies for uppercase letters, e.g., our 'A' = their 'Z', etc.
// Write a function that takes a string as input, and returns the Bizarro 
// World equivalent.  NASA scientists have figured out some of the code for you.
// Replace the TODO: comments with the code that ought to be there.
// Note that punctuation characters and symbols should be preserved, i.e., they are the same 
// in both worlds.  This should be remind you of the Caesar's Cypher problem.

// It may be helpful to revisit your code from Exam 2 for ideas!
// NOTE: the function you create will, by definition, also
// decrypt the bizarro message (it is invertible).

// Please submit your Lab Section solutions (in one file, named 
// username_final_L1.cpp, where username is your student email username 
// before the @ sign) via email to: james.dittrich+YSU@gmail.com

// ===== BEGIN NASA Example code ===== 

#include <iostream>
// TODO: insert the appropriate library includes for what 
// functions that you need (and actually use).
using namespace std;

// TODO: complete the logic for the Bizarro translation function below.
string bizarro(string message){
	string upperAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string lowerAlphabet = "abcdefghijklmnopqrstuvwxyz";
	string alphabet = upperAlphabet + lowerAlphabet;
	string revUpper = ""; // see below: reverse the uppercase alphabet string above
	string revLower = ""; // see below: reverse the lowercase alphabet string above
	string reversed; // concatenate the reversed alphabets in the correct order, preserving case
	string bizarroMessage; // this will store the encoded message

	// DEBUG:
	cout << "\nAlphabet: " << alphabet << endl;

	
	// TODO: Reverse the two alphabet strings by looping backwards.
	//       Start at the last index and work back to 0.
	//       Concatenate the letter onto the reverse string.
	//       Assigning this value by hand is WRONG! See below.

	// DEBUG:
	cout << "\nReversed alphabet: " << reversed << endl; //this should match case order of alphabet

	// TODO: Loop through the message: find the index of the current
	//       letter. 
	//		 If it's found (in the ascii alphabet), use that index 
	// 		 to get the value of the letter at that same position
	//       in the reverse alphabet string, and concatenate that letter.
	//       If it's not found, just concatenate the original (non-alphabetic) character.

	return bizarroMessage;
}

int main(){
	string userInput;
	string testMessage = "Gzpv nv gl blfi ovzwvi, Vzigsormt.\nPozzgf, Yzizwz, Mrpgl.\nOrev olmt zmw kilhkvi!";

	// TODO: call the bizarro function using the test message. It contains references to classic Sci-Fi films.
	cout << bizarro(testMessage) << endl;

	// TODO: prompt the user for input.  Translate their input to Bizarro text.
	// The input should capable of translating an entire line (including whitespace).

	cout << bizarro(userInput) << endl;

	// TODO: ask the user if they would like to "translate another message?(y/n): ". If 'y', loop.
	// If 'n', then exit the program.

	return 0;
}
