diff --git a/README.md b/README.md index 12e5c64..ff6996e 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,77 @@ # cpp-beginner-projects ## 📖 Overview -This repository contains beginner-friendly C++ projects created while learning programming fundamentals. +This repository contains beginner-friendly C++ console projects to practice programming fundamentals through small, practical programs. -It is designed to practice: -- Input / Output -- Conditional statements +These projects mainly focus on: +- Input and output +- Conditional logic (`if/else`, `switch`) - Loops -- Switch-case -- Basic validation and calculations +- Basic calculations and validation --- -## ⚙️ Repository Structure -Each `.cpp` file is an independent console program. - -### 📂 Projects -- **Bill_Splitter.cpp** – Split a bill among multiple people. -- **Cutoff_Checker.cpp** – Check pass/fail with overall and subject cutoffs. -- **Day_Name_And_Type.cpp** – Find day name and identify weekday/weekend. -- **Electricity_Bill_Calculator.cpp** – Calculate bill using unit slabs. -- **Grade_Evaluator.cpp** – Evaluate grade from marks. -- **Mini_ATM.cpp** – Basic ATM simulation (balance, deposit, withdraw). -- **Movie_Ticket_Counter.cpp** – Calculate ticket amount by category. -- **Petrol_Pump_Dispensor.cpp** – Fuel billing by amount or liters. -- **Simple_Calculator.cpp** – Perform basic arithmetic operations. -- **Smart_Card_Fare_System.cpp** – Metro fare and balance check system. -- **Table_Maker.cpp** – Generate multiplication tables. -- **Temperature_Converter.cpp** – Convert Celsius and Fahrenheit. -- **Voting_Eligibility_Checker.cpp** – Check voting eligibility by age. -- **Water_State_Checker.cpp** – Determine water state from temperature. +## ⚙️ How This Repository Works +- Each `.cpp` file is an independent project. +- You can compile and run each project separately. +- Every project has its own detailed README in [`project-readmes/`](./project-readmes/) with: + - Overview + - How It Works + - Requirements + - Compile & Run + +--- + +## 📂 Projects and Detailed READMEs +1. [Bill Splitter](./project-readmes/Bill_Splitter.md) +2. [Cutoff Checker](./project-readmes/Cutoff_Checker.md) +3. [Day Name And Type](./project-readmes/Day_Name_And_Type.md) +4. [Electricity Bill Calculator](./project-readmes/Electricity_Bill_Calculator.md) +5. [Grade Evaluator](./project-readmes/Grade_Evaluator.md) +6. [Mini ATM](./project-readmes/Mini_ATM.md) +7. [Movie Ticket Counter](./project-readmes/Movie_Ticket_Counter.md) +8. [Petrol Pump Dispensor](./project-readmes/Petrol_Pump_Dispensor.md) +9. [Simple Calculator](./project-readmes/Simple_Calculator.md) +10. [Smart Card Fare System](./project-readmes/Smart_Card_Fare_System.md) +11. [Table Maker](./project-readmes/Table_Maker.md) +12. [Temperature Converter](./project-readmes/Temperature_Converter.md) +13. [Voting Eligibility Checker](./project-readmes/Voting_Eligibility_Checker.md) +14. [Water State Checker](./project-readmes/Water_State_Checker.md) --- ## 🛠️ Requirements -- A C++ compiler (e.g., `g++`) +- A C++ compiler (for example, `g++`) - Terminal / command prompt --- -## ▶️ How to Run +## ▶️ How to Run Any Project 1. Clone the repository: ```bash git clone https://github.com/yash-kumar-18/cpp-beginner-projects.git cd cpp-beginner-projects ``` -2. Compile any file (example: `Simple_Calculator.cpp`): +2. Compile a project (example: `Simple_Calculator.cpp`): ```bash g++ Simple_Calculator.cpp -o Simple_Calculator ``` -3. Run the program: +3. Run it: ```bash ./Simple_Calculator ``` -4. Repeat the same steps for any other `.cpp` file. +> Repeat the same compile-and-run process for other `.cpp` files. --- ## 📄 License This project is licensed under the **MIT License**. -See the full license text in the [`LICENSE`](./LICENSE) file. +See [`LICENSE`](./LICENSE) for full details. --- ## 🎯 Goal -To build strong C++ basics through small and practical projects. +Build strong C++ basics with project-based learning. diff --git a/project-readmes/Bill_Splitter.md b/project-readmes/Bill_Splitter.md new file mode 100644 index 0000000..ae7a03a --- /dev/null +++ b/project-readmes/Bill_Splitter.md @@ -0,0 +1,20 @@ +# Bill_Splitter.cpp + +## Overview +This project splits a total bill amount among multiple people. + +## How It Works +- Takes total bill amount as input. +- Takes total number of persons. +- Validates that persons are not zero. +- Calculates and prints bill per person. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Bill_Splitter.cpp -o Bill_Splitter +./Bill_Splitter +``` diff --git a/project-readmes/Cutoff_Checker.md b/project-readmes/Cutoff_Checker.md new file mode 100644 index 0000000..0cd4ef3 --- /dev/null +++ b/project-readmes/Cutoff_Checker.md @@ -0,0 +1,21 @@ +# Cutoff_Checker.cpp + +## Overview +This project checks pass/fail status using overall marks and individual subject cutoffs. + +## How It Works +- Accepts theory and practical marks. +- Validates both marks are between 0 and 50. +- Checks overall cutoff (total at least 40). +- Checks individual cutoffs (theory and practical at least 15 each). +- Prints pass/fail reason. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Cutoff_Checker.cpp -o Cutoff_Checker +./Cutoff_Checker +``` diff --git a/project-readmes/Day_Name_And_Type.md b/project-readmes/Day_Name_And_Type.md new file mode 100644 index 0000000..bbd85e7 --- /dev/null +++ b/project-readmes/Day_Name_And_Type.md @@ -0,0 +1,20 @@ +# Day_Name_And_Type.cpp + +## Overview +This project maps a day number (1 to 7) to day name and identifies weekday/weekend. + +## How It Works +- Accepts a day number input. +- Uses `switch` to print the corresponding day name. +- Validates valid range (1 to 7). +- Uses another `switch` to print whether the day is a weekday or weekend. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Day_Name_And_Type.cpp -o Day_Name_And_Type +./Day_Name_And_Type +``` diff --git a/project-readmes/Electricity_Bill_Calculator.md b/project-readmes/Electricity_Bill_Calculator.md new file mode 100644 index 0000000..f5dad98 --- /dev/null +++ b/project-readmes/Electricity_Bill_Calculator.md @@ -0,0 +1,24 @@ +# Electricity_Bill_Calculator.cpp + +## Overview +This project calculates electricity bill using slab-based per-unit charges. + +## How It Works +- Takes total units consumed. +- Applies slab rates: + - Up to 100 units: 5 per unit + - 101 to 200 units: 7 per unit + - 201 to 300 units: 9 per unit + - Above 300 units: 11 per unit +- Validates units are non-negative. +- Prints final bill amount. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Electricity_Bill_Calculator.cpp -o Electricity_Bill_Calculator +./Electricity_Bill_Calculator +``` diff --git a/project-readmes/Grade_Evaluator.md b/project-readmes/Grade_Evaluator.md new file mode 100644 index 0000000..4a9decd --- /dev/null +++ b/project-readmes/Grade_Evaluator.md @@ -0,0 +1,24 @@ +# Grade_Evaluator.cpp + +## Overview +This project evaluates grade based on entered marks. + +## How It Works +- Accepts marks input. +- Uses `if/else if` ranges to assign grades: + - A: 90 and above + - B: 75 to 89 + - C: 50 to 74 + - D (Pass): 33 to 49 + - F (Fail): below 33 +- Prints the grade. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Grade_Evaluator.cpp -o Grade_Evaluator +./Grade_Evaluator +``` diff --git a/project-readmes/Mini_ATM.md b/project-readmes/Mini_ATM.md new file mode 100644 index 0000000..ecd04c0 --- /dev/null +++ b/project-readmes/Mini_ATM.md @@ -0,0 +1,21 @@ +# Mini_ATM.cpp + +## Overview +This project simulates basic ATM operations with a starting balance. + +## How It Works +- Starts with a default balance of 1000. +- Shows menu options: check balance, deposit, withdraw, exit. +- Validates positive deposit/withdrawal amounts. +- Checks balance before withdrawal. +- Prints result based on selected option. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Mini_ATM.cpp -o Mini_ATM +./Mini_ATM +``` diff --git a/project-readmes/Movie_Ticket_Counter.md b/project-readmes/Movie_Ticket_Counter.md new file mode 100644 index 0000000..9ab66f9 --- /dev/null +++ b/project-readmes/Movie_Ticket_Counter.md @@ -0,0 +1,24 @@ +# Movie_Ticket_Counter.cpp + +## Overview +This project calculates movie ticket total based on screen type, age, and number of persons. + +## How It Works +- Lets user select ticket category: + - Standard + - IMAX 3D + - VIP Lounge +- Accepts age and number of tickets. +- Applies VIP pricing with senior-citizen discount for age 60+. +- Validates menu choice, age, and ticket count. +- Prints total payable amount. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Movie_Ticket_Counter.cpp -o Movie_Ticket_Counter +./Movie_Ticket_Counter +``` diff --git a/project-readmes/Petrol_Pump_Dispensor.md b/project-readmes/Petrol_Pump_Dispensor.md new file mode 100644 index 0000000..2b80e66 --- /dev/null +++ b/project-readmes/Petrol_Pump_Dispensor.md @@ -0,0 +1,23 @@ +# Petrol_Pump_Dispensor.cpp + +## Overview +This project simulates fuel billing by fuel type and dispensing mode. + +## How It Works +- Lets user choose fuel type (Petrol, Diesel, CNG). +- Lets user choose dispensing mode: + - By amount (Rs) + - By volume (L) +- Validates fuel type and mode choices. +- Validates entered amount/volume is greater than zero. +- Calculates either fuel quantity from amount or bill amount from volume. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Petrol_Pump_Dispensor.cpp -o Petrol_Pump_Dispensor +./Petrol_Pump_Dispensor +``` diff --git a/project-readmes/Simple_Calculator.md b/project-readmes/Simple_Calculator.md new file mode 100644 index 0000000..f15e9e9 --- /dev/null +++ b/project-readmes/Simple_Calculator.md @@ -0,0 +1,21 @@ +# Simple_Calculator.cpp + +## Overview +This project performs basic arithmetic operations between two numbers. + +## How It Works +- Accepts two numbers. +- Accepts an operator (`+`, `-`, `*`, `/`). +- Uses `switch` to run the selected operation. +- Handles division by zero with an error message. +- Shows error for invalid operator input. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Simple_Calculator.cpp -o Simple_Calculator +./Simple_Calculator +``` diff --git a/project-readmes/Smart_Card_Fare_System.md b/project-readmes/Smart_Card_Fare_System.md new file mode 100644 index 0000000..1e53477 --- /dev/null +++ b/project-readmes/Smart_Card_Fare_System.md @@ -0,0 +1,21 @@ +# Smart_Card_Fare_System.cpp + +## Overview +This project calculates metro fare between sectors and checks card balance deduction. + +## How It Works +- Starts with fixed smart card balance of 200. +- Accepts departure and destination points (1 to 5). +- Validates points and prevents same entry/exit. +- Calculates fare as distance between points × 10. +- Checks sufficient balance and prints remaining balance. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Smart_Card_Fare_System.cpp -o Smart_Card_Fare_System +./Smart_Card_Fare_System +``` diff --git a/project-readmes/Table_Maker.md b/project-readmes/Table_Maker.md new file mode 100644 index 0000000..21d2379 --- /dev/null +++ b/project-readmes/Table_Maker.md @@ -0,0 +1,20 @@ +# Table_Maker.cpp + +## Overview +This project generates a multiplication table for a given number. + +## How It Works +- Accepts a number for table generation. +- Accepts a limit up to which table should be printed. +- Validates that number is greater than zero. +- Uses a loop to print multiplication results from 1 to limit. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Table_Maker.cpp -o Table_Maker +./Table_Maker +``` diff --git a/project-readmes/Temperature_Converter.md b/project-readmes/Temperature_Converter.md new file mode 100644 index 0000000..e8157fa --- /dev/null +++ b/project-readmes/Temperature_Converter.md @@ -0,0 +1,23 @@ +# Temperature_Converter.cpp + +## Overview +This project converts temperature between Celsius and Fahrenheit. + +## How It Works +- Lets user choose conversion direction: + - Celsius to Fahrenheit + - Fahrenheit to Celsius +- Validates conversion option. +- Performs selected conversion formula. +- Supports repeated calculations using `y/n` prompt. +- Validates repeat input. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Temperature_Converter.cpp -o Temperature_Converter +./Temperature_Converter +``` diff --git a/project-readmes/Voting_Eligibility_Checker.md b/project-readmes/Voting_Eligibility_Checker.md new file mode 100644 index 0000000..617ee92 --- /dev/null +++ b/project-readmes/Voting_Eligibility_Checker.md @@ -0,0 +1,20 @@ +# Voting_Eligibility_Checker.cpp + +## Overview +This project checks whether a person is eligible to vote based on age. + +## How It Works +- Accepts age input. +- Validates age is greater than zero. +- If age is below 18, prints not eligible. +- If age is 18 or above, prints eligible. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Voting_Eligibility_Checker.cpp -o Voting_Eligibility_Checker +./Voting_Eligibility_Checker +``` diff --git a/project-readmes/Water_State_Checker.md b/project-readmes/Water_State_Checker.md new file mode 100644 index 0000000..00e06b0 --- /dev/null +++ b/project-readmes/Water_State_Checker.md @@ -0,0 +1,20 @@ +# Water_State_Checker.cpp + +## Overview +This project determines the physical state of water from input temperature. + +## How It Works +- Accepts water temperature in Celsius. +- If temperature is below 0, output is solid state. +- If temperature is 100 or above, output is gaseous state. +- Otherwise, output is liquid state. + +## Requirements +- C++ compiler (`g++`) +- Terminal + +## Compile & Run +```bash +g++ Water_State_Checker.cpp -o Water_State_Checker +./Water_State_Checker +```