From c4e7aa47d0fed0de291877fba6c938905c3ddf0f Mon Sep 17 00:00:00 2001 From: Habiba Sorour Date: Fri, 24 Jul 2026 17:18:33 +0300 Subject: [PATCH] added comments to code blocks in 3.1 --- source/ch3_javadatatypes.ptx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/ch3_javadatatypes.ptx b/source/ch3_javadatatypes.ptx index e33d9b1..39defc9 100644 --- a/source/ch3_javadatatypes.ptx +++ b/source/ch3_javadatatypes.ptx @@ -99,8 +99,9 @@ def main(): - fahr = int(input("Enter the temperature in F: ")) - cel = (fahr - 32) * 5.0/9.0 + """ Program to convert a temperature from Fahrenheit to Celsius. """ + fahr = int(input("Enter the temperature in F: ")) # get the temperature in Fahrenheit + cel = (fahr - 32) * 5.0/9.0 # convert to Celsius print("the temperature in C is: ", cel) main() @@ -115,16 +116,19 @@ main() -import java.util.Scanner; +import java.util.Scanner; // import the Scanner class to read input from the user + /** + * Program to convert a temperature from Fahrenheit to Celsius in Java. + */ public class TempConv { public static void main(String[] args) { - Double fahr; + Double fahr; Double cel; - Scanner in; - in = new Scanner(System.in); + Scanner in; // declare a Scanner variable called in + in = new Scanner(System.in); // create a Scanner object to read input from the user System.out.println("Enter the temperature in F: "); - fahr = in.nextDouble(); - cel = (fahr - 32) * 5.0/9.0; + fahr = in.nextDouble(); // read the temperature in Fahrenheit from the user + cel = (fahr - 32) * 5.0/9.0; // convert to Celsius System.out.println("The temperature in C is: " + cel); } }