From b01852fd114031f350ade86f0efe2ecd140c2211 Mon Sep 17 00:00:00 2001 From: fami <2220002370@iau.edu.sa> Date: Sat, 2 Mar 2024 12:58:35 +0300 Subject: [PATCH 1/2] temp --- bin/App.class | Bin 562 -> 562 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/App.class b/bin/App.class index baa6c6726ecc7ff0468f1be52445c21d3cbd1d3d..d29bb04f370f0467cab0b08c94402057ca0af384 100644 GIT binary patch delta 17 ZcmdnQvWbP`)W2Q({{Lri+{mHD1OQC!2iX7s delta 17 ZcmdnQvWbP`)W2Q(7#J9AH*#n(0RTPd1=j!o From 149d5f4c1058e143e0cbd04b2270759368445258 Mon Sep 17 00:00:00 2001 From: fami <2220002370@iau.edu.sa> Date: Sat, 2 Mar 2024 13:15:13 +0300 Subject: [PATCH 2/2] Done --- README.md | 208 +++++--------------------------------------------- bin/App.class | Bin 562 -> 2272 bytes src/App.java | 42 +++++++++- 3 files changed, 60 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index a937cfb..2c70c4f 100644 --- a/README.md +++ b/README.md @@ -1,188 +1,20 @@ -# Level 1.3: Temperature Converter (Java) - -## Table of Contents - -- [Overview](#overview) -- [Learning Objectives](#learning-objectives) -- [Setup and Tutorial](#setup-and-tutorial) -- [Project Overview](#project-overview) -- [Submission Guidelines](#submission-guidelines) - - - -## overview - -This Java program converts temperatures between Celsius and Fahrenheit. It repeatedly prompts the user to choose the conversion type and input a temperature, then performs the conversion and displays the result. The program continues until the user chooses to exit. - -## learning-objectives - -1.Implementing User Input: Gain experience in prompting users for input and reading input from the console using Java. - -2.Conditional Statements: Learn how to use conditional statements such as if-else or switch cases to make decisions in the program based on user input. - -3.Looping Constructs: Understand how to implement loops to allow the program to perform multiple conversions until the user chooses to exit. - -4.Variable Manipulation: Practice working with variables to store and manipulate temperature values during the conversion process. - -5.Algorithmic Thinking: Develop problem-solving skills by devising an algorithm to convert temperatures accurately based on the chosen conversion type. - -6.Graceful Program Exit: Learn how to implement a mechanism for the user to exit the program smoothly when they are finished using it. - - -## setup-and-tutorial - -### 1. Setup - -#### 1.1 Java Development Kit (JDK) - -Make sure you have Java Development Kit (JDK) installed on your system. You can download and install JDK from the official Oracle website: [Java SE Downloads](https://www.oracle.com/java/technologies/javase-downloads.html) - -#### 1.2 Integrated Development Environment (IDE) - -Choose an Integrated Development Environment (IDE) for Java development. Some popular options include: -- [visual studio code](https://code.visualstudio.com) -- [IntelliJ IDEA](https://www.jetbrains.com/idea/) - -Download and install the IDE of your choice. - -### 2. Tutorial - -#### 2.1 Java Basics - -If you're new to Java programming, it's essential to understand the basics of the language. You can find numerous tutorials and resources online to learn Java. Here are some key topics to cover: -- Java syntax: variables, data types, operators, etc. -- Input/output using `System.out.println` and `Scanner` class. -- Control flow statements: if-else, switch-case, loops. - -#### 2.2 Temperature Conversion Algorithm - -Before diving into coding, plan the algorithm for temperature conversion. Break down the task into smaller steps: -- Prompt the user to choose the conversion type. -- Based on the choice, prompt for the temperature to be converted. -- Perform the conversion and display the result. -- Implement a loop to repeat the process until the user chooses to exit. -- Here is an example of how to use the `while` Loop. -```java -import java.util.Scanner; - -public class Main { - public static void main(String[] args) { - Scanner scanner = new Scanner(System.in); - String input; - - while (true) { - System.out.print("Enter a number (or 'exit' to quit): "); - input = scanner.nextLine(); - - if (input.equalsIgnoreCase("exit")) { - break; - } - System.out.println("Goodbye!"); - scanner.close(); - } -} -} -``` - -#### 2.3 Coding the Temperature Converter - -Start coding the Temperature Converter project in your chosen IDE: -- Create a new Java project. -- Implement the main logic of the program: - - Implement a loop for repeated conversions. - - Use conditional statements to determine the conversion type. - - Prompt the user for input using the `Scanner` class. - - Perform the conversion based on the chosen type. - - Display the result. - - Provide an option for the user to exit gracefully. -- Test the program with various inputs to ensure it functions correctly. - - -#### 2.4 Documentation and Sharing - -Document your code with comments to explain the functionality of each part. Create a README.md file to provide instructions on how to use the program and include any necessary setup steps. Share your project with others in the programming club for feedback and collaboration. - - -## How to Use - -1. Run the Java program. -2. Choose the conversion type: - - Celsius to Fahrenheit - - Fahrenheit to Celsius - - Exit -3. Enter the temperature to be converted. -4. The program will display the converted temperature. -5. Repeat steps 2-4 for multiple conversions. -6. To exit the program, choose the "Exit" option. - -## Project Overview: - -### Description - -This Java project focuses on creating a Temperature Converter program that allows users to convert temperatures between Celsius and Fahrenheit. The program interacts with users through the console, prompting them to choose the conversion type and input a temperature. It then performs the conversion and displays the result. The program continues to run until the user chooses to exit. - -### Requirements - -1. **Loop Implementation:** - - Implement a loop to enable users to perform multiple temperature conversions without restarting the program. - -2. **Conditional Statements:** - - Use conditional statements (if-else or switch cases) to determine the conversion type based on user input. - -3. **Conversion Options:** - - Provide options for users to choose between Celsius to Fahrenheit conversion and Fahrenheit to Celsius conversion. - -4. **User Input:** - - Prompt the user to input the temperature to be converted. - -5. **Conversion Logic:** - - Implement the conversion logic based on the chosen type (Celsius to Fahrenheit or Fahrenheit to Celsius). - -6. **Display Result:** - - Display the converted temperature to the user. - -7. **Graceful Program Exit:** - - Allow users to exit the program gracefully when they choose to stop. - -### Example Interaction -Temperature Converter - -Choose conversion type: - -Celsius to Fahrenheit -Fahrenheit to Celsius -Exit -Enter your choice: 1 -Enter the temperature in Celsius: 25 -25.0°C is equal to 77.0°F - -Choose conversion type: - -Celsius to Fahrenheit -Fahrenheit to Celsius -Exit -Enter your choice: 2 -Enter the temperature in Fahrenheit: 98.6 -98.6°F is equal to 37.0°C - -Choose conversion type: - -Celsius to Fahrenheit -Fahrenheit to Celsius -Exit -Enter your choice: 3 -Exiting the program. Goodbye! - -### Bonus - -- Enhance the user interface with ASCII art or additional messages for a more engaging experience. -- Implement error handling to manage unexpected inputs gracefully. - - -## Submission Guidelines - -- The app should be pushed to Github and a pull request should be created. You can check how to push your code to Github in section [2.1.2 Add Changes](https://github.com/Programming-Club-IAU/git-and-github#212-add-changes). -- The pull request title should be in the following format: ` - `. You can check how to make a pull request in section [2.1.5. Create a pull request](ttps://github.com/Programming-Club-IAU/git-and-github#215-create-a-pull-request). -- The pull request description should contain the following: - - A description of your project. - - A screenshot of the app. \ No newline at end of file +## Tempreture Converter readme file + +==== INTRODUCTION ==== +Program language : Java +Program name : Tempreture converter +The Inputs : tempretrue choice, tempretrue in fahrenhite, tempretrue in celsuis. +The output : Exiting the program, convert tempreture to fahrenhite, convert tempreture to celsuis. +Equations : cel=fah*(5/9.0)-32.0 , fah=cel*(9/5.0)+32.0 +Requirement : loop , if cases, user input, handling errors, exiting fluintly. + +====BRIFE ABOUT THE PROGRAM==== +The Program created to help the user wiht converting tempreture to the other tempreture by first started the program to show a menu +to let the user choice the wanted process. + +- If the user choice to convert to celsuis it will take the tempreture in fahrenhite, and it will be caluculated to find the result + and show to the user. +- If the user choice to convert to fahrenhite, it will take the tempreture in celsuis then caluclated to show the result to the user. +- If the user choice to exit the program it will immediatly end the process, and show a thank message to the user. + Other then these option, it will ask the user if it want to exit the program or he accedantlylet the cat walk on keybaord. If it yes + then the same result as exit choice ,else it will be asking to write a correct choice and show the menu again. diff --git a/bin/App.class b/bin/App.class index d29bb04f370f0467cab0b08c94402057ca0af384..5b3af32bc74b2a3449a0ef221691ecc75f1f74c4 100644 GIT binary patch literal 2272 zcmb7FTW=dx5dKaQdpBE`=3b`_?S`fhr=%un18E&6P3?rbIBkgCl+bcH*__xLuXo+u zb=3R;ctqj_#8bpeUXTzKYNdjZkU$j(gm^;m#_!-#=B(Y=ZBwM~!@10v`DW%jGiQJN z_wG0M?_(Al3R)OiXDby2Z44b7e3Qp5ZWrR0S2u*=GlZv1+w`YNX*jmb(3W!6goakM zM-W1o;Xu~3#ieR_Rk(S+Y6*s}tYdI%nY*Uk*M)6<(exNXS#p&im@+qQhQ8rz*@nxU z@0xZY5nEQ!$`K)q zRKd#$4ISv0F&|=x4)3WFTb3RMB6t=@C|{>a={LX@DYyq)jAcEs~o}xIrHd7(>guVYV;Vvm8?C$6Q^NAhswd-`=S5f8MPd5d`0jZ_C{^m(+NsgG zo2IYli{e4#+O!OKB!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%X@m14Afx|DuUgQ z^VOG1`a07$}WVt2Um|d}3li@D#j(0&KR=F>+=`w9#Qk J=<+nM`2~8&Nt^%x diff --git a/src/App.java b/src/App.java index 0a839f9..2ed3565 100644 --- a/src/App.java +++ b/src/App.java @@ -1,5 +1,43 @@ +import java.util.Scanner; public class App { - public static void main(String[] args) throws Exception { - System.out.println("Hello, World!"); + public static void main(String[] args){ + Scanner input = new Scanner(System.in); + System.out.println("===========Welcome To Temprture Converter Program==========="); + int choice=0; + double fah,cel; + int answare; + while (choice!=3){ + System.out.print("Enter Your Choice\n1-Convert Celsius To Fahrenheit\n2-Convert Fahrenheit To Celsius\n3-Exit The Program\n>"); + choice=input.nextInt(); + if(choice==1){ + System.out.print("Enter The Tempreture In Celsius: "); + cel=input.nextDouble(); + fah=cel*(9/5.0)+32.0; + System.out.println("The Tempreture "+cel+" In Celsius Is Equalivent To "+fah+" In Fahrenheit"); + System.out.println("======================================================="); + } + else if(choice==2){ + System.out.print("Enter The Tempreture In Fahrenheit: "); + fah=input.nextDouble(); + cel=fah*(5/9.0)-32.0; + System.out.println("The Tempreture "+fah+" In Fahrenheit Is Equalivent To "+cel+" In Celsius"); + System.out.println("======================================================="); + } + else if(choice==3){ + break; + } + else{ + System.out.print("Are You Trying To Exit?\n1=Yes\t2=No\n>"); + choice=input.nextInt(); + if(choice==2){ + System.out.print("Please Enter The Right Choice Again"); + System.out.println("\n======================================================="); + } + if(choice==1) + break; + } + } + System.out.println("======================================================="); + System.out.println(" Thank You For Using My Program\n\tPlease Rate Later\n"); } }