SlideShare a Scribd company logo
1 of 2
Download to read offline
CS 115 DEMO QUESTION!
TA: Aditya Parakh
This is a demo question. Attempt this question at your own will. No extra credit is being offered for this question.!
!
Checklist before you start: !
__ Know how to comment!
__ Know how to write/define constants!
__ Know how to use Scanner to get user input!
__ Know how to use Switch/Case statement !
__ Know how to convert Strings to char (using charAt())!
__ Know how to use different types of loops !
!
!
!
!
!
Question 1: You are writing a program that will guess the name of your TA based on
inputs given. You will utilize switch/case statements along with loops in this task.!
!
1) Insert a comment at the start of the program describing what the program does!
2) Declare a constant called AWESOMEMIN and initialize it to 22!
3) Declare a constant called AWESOMEMAX and initialize it to 83!
4) Ask user for their name and store it in a String variable called “usrName”!
5) Use a switch/case statement to do the following: !
I. If the first letter of the name is ‘A’ or ‘a’: Print “Aditya Parakh”!
II. If the first letter of the name is ‘B’ or ‘b’: Print “Barney Stinson” !
III. If the first letter of the name is ‘P’ or ‘p’: Print “Parakh?”!
IV. If anything else: Print the name entered by user!
6) After the switch case. Print “Suit up” and the name guessed. Example “Suit up
Aditya Parakh” or “Suit Up Lion Tiger” !
7) Print the number of characters in the first word of the name: !
8) Use a loop to ask the user for an awesome count (double) that is !
1) Greater than AWESOMEMIN!
2) Smaller than AWESOMEMAX!
9) It should look like this “What is your awesome count?:”!
10) TESTING FOR DOUBLE!
1) Check to make sure the user has entered a double.!
2) If the user fails to enter a double (enters a string or int):!
1) Print “Enter a double:”!
2) Scan the user input and store it in a String variable of Garbage.!
11) Assuming user has entered a double. If the double entered is less than
AWESOMEMIN: Print “AWESOME COUNT TOO LOW. PLEASE ENTER NUM
BIGGER THAN” and put in the AWESOMEMIN count after that. !
12) If the double entered is bigger than AWESOMEMAX. Print “AWESOME COUNT
TOO HIGH. PLEASE ENTER NUM SMALLER THAN” and put in AWESOMEMAX
count after that. !
13) If the num entered is between AWESOMEMIN AND AWESOMEMAX. Print “The
amount of awesomeness is” and then display AWESOMEMAX. !
CS 115 DEMO QUESTION!
TA: Aditya Parakh
14) !

More Related Content

Similar to DemoQues

Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)
Charling Li
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
Connex
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
Jussi Pohjolainen
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 

Similar to DemoQues (20)

Beyond the Style Guides
Beyond the Style GuidesBeyond the Style Guides
Beyond the Style Guides
 
Python comments and variables.pptx
Python comments and variables.pptxPython comments and variables.pptx
Python comments and variables.pptx
 
Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)Coding in Disaster Relief - Worksheet (Advanced)
Coding in Disaster Relief - Worksheet (Advanced)
 
Python
PythonPython
Python
 
Naming Standards, Clean Code
Naming Standards, Clean CodeNaming Standards, Clean Code
Naming Standards, Clean Code
 
ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1ACM init() Spring 2015 Day 1
ACM init() Spring 2015 Day 1
 
N E T Coding Best Practices
N E T  Coding  Best  PracticesN E T  Coding  Best  Practices
N E T Coding Best Practices
 
Presentation 2nd
Presentation 2ndPresentation 2nd
Presentation 2nd
 
Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.Wade not in unknown waters. Part two.
Wade not in unknown waters. Part two.
 
Visual basic asp.net programming introduction
Visual basic asp.net programming introductionVisual basic asp.net programming introduction
Visual basic asp.net programming introduction
 
Fortran 90 Basics
Fortran 90 BasicsFortran 90 Basics
Fortran 90 Basics
 
Programming with Java: the Basics
Programming with Java: the BasicsProgramming with Java: the Basics
Programming with Java: the Basics
 
Cosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutletCosc 1436 java programming/tutorialoutlet
Cosc 1436 java programming/tutorialoutlet
 
JavaScript: Core Part
JavaScript: Core PartJavaScript: Core Part
JavaScript: Core Part
 
Class9 js word_quar2018
Class9 js word_quar2018Class9 js word_quar2018
Class9 js word_quar2018
 
Perfect Code
Perfect CodePerfect Code
Perfect Code
 
null Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injectionnull Pune meet - Application Security: Code injection
null Pune meet - Application Security: Code injection
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 

DemoQues

  • 1. CS 115 DEMO QUESTION! TA: Aditya Parakh This is a demo question. Attempt this question at your own will. No extra credit is being offered for this question.! ! Checklist before you start: ! __ Know how to comment! __ Know how to write/define constants! __ Know how to use Scanner to get user input! __ Know how to use Switch/Case statement ! __ Know how to convert Strings to char (using charAt())! __ Know how to use different types of loops ! ! ! ! ! ! Question 1: You are writing a program that will guess the name of your TA based on inputs given. You will utilize switch/case statements along with loops in this task.! ! 1) Insert a comment at the start of the program describing what the program does! 2) Declare a constant called AWESOMEMIN and initialize it to 22! 3) Declare a constant called AWESOMEMAX and initialize it to 83! 4) Ask user for their name and store it in a String variable called “usrName”! 5) Use a switch/case statement to do the following: ! I. If the first letter of the name is ‘A’ or ‘a’: Print “Aditya Parakh”! II. If the first letter of the name is ‘B’ or ‘b’: Print “Barney Stinson” ! III. If the first letter of the name is ‘P’ or ‘p’: Print “Parakh?”! IV. If anything else: Print the name entered by user! 6) After the switch case. Print “Suit up” and the name guessed. Example “Suit up Aditya Parakh” or “Suit Up Lion Tiger” ! 7) Print the number of characters in the first word of the name: ! 8) Use a loop to ask the user for an awesome count (double) that is ! 1) Greater than AWESOMEMIN! 2) Smaller than AWESOMEMAX! 9) It should look like this “What is your awesome count?:”! 10) TESTING FOR DOUBLE! 1) Check to make sure the user has entered a double.! 2) If the user fails to enter a double (enters a string or int):! 1) Print “Enter a double:”! 2) Scan the user input and store it in a String variable of Garbage.! 11) Assuming user has entered a double. If the double entered is less than AWESOMEMIN: Print “AWESOME COUNT TOO LOW. PLEASE ENTER NUM BIGGER THAN” and put in the AWESOMEMIN count after that. ! 12) If the double entered is bigger than AWESOMEMAX. Print “AWESOME COUNT TOO HIGH. PLEASE ENTER NUM SMALLER THAN” and put in AWESOMEMAX count after that. ! 13) If the num entered is between AWESOMEMIN AND AWESOMEMAX. Print “The amount of awesomeness is” and then display AWESOMEMAX. !
  • 2. CS 115 DEMO QUESTION! TA: Aditya Parakh 14) !