15 || decimal < 0) System.out.println("Invalid input"); else if (decimal 1-) System.out.println("The hex value is " + decimal); else System.out.println("The hex value is " + (char)('A' + decimal - 10)); }"> 15 || decimal < 0) System.out.println("Invalid input"); else if (decimal 1-) System.out.println("The hex value is " + decimal); else System.out.println("The hex value is " + (char)('A' + decimal - 10)); }">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014.

Similar presentations


Presentation on theme: "CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014."— Presentation transcript:

1 CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014

2 here is the new site: https://cs110java.wikispaces.com/ https://cs110java.wikispaces.com/

3 What is output by the following programs? import java.util.Scanner; public class lab5_1 { public static void main(String args[]) { Scanner input = new Scanner(System.in); System.out.print("Enter a decimal value (0 to 15): "); int decimal = input.nextInt(); // the user will enter 12 if (decimal > 15 || decimal < 0) System.out.println("Invalid input"); else if (decimal 1-) System.out.println("The hex value is " + decimal); else System.out.println("The hex value is " + (char)('A' + decimal - 10)); }

4

5 Problem Description Write a program that convert currency from U.S. dollars $ to Saudi riyal SR or vice. Prompt the user to enter 1 to convert from $ to SR 0 to convert from SR and $. Prompt the user to enter the amount to convert it to what she chose Sample output:

6 Code Skelton

7 Follow-up Questions and Activities Try to modify the last code from Switch to If statements.

8 Evaluation By using Switch write a program that prompt the user to enter a character between A and C and display the arrangement of this character If the user enter something else print (Invalid input) Sample output: Enter a letter from A to C: C The arrangement of this character is 3


Download ppt "CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014."

Similar presentations


Ads by Google