Write a console application in your preferred language which will work as a help
ID: 3576387 • Letter: W
Question
Write a console application in your preferred language which will work as a help or reference
application for users. The application should show a main menu;
Select the topic you need help with;
1. Data Types
2. Variable Declarations
3. Variable Initializations
4. Assignment Statements
5. Arithmetic Expressions
6. Relational and Boolean Expressions
7. Type Conversions
8. Selection Statements
9. Iterative Statements
10. <QUIT>
For each selection, the next menu should be the list of the languages;
Select the language for the topic <selected topic>. Enter 0 to Go Back;
1. Java
2. C
3. C++
4. C#
5. Python
6. JavaScript
7. PHP
8. Ruby
9. <Go Back>
For the first seven option from the first menu, give a short description and three examples.
Examples should not copied from the text book.
Let's say user has selected Variable Declarations and then Ruby. A sample output would be;
Ruby Variable Declarations:
To save and remember a value, we use variables. A variable will be defined
using a name, which will then be used to store a value or set of values,
depending on the data type.
In Ruby, everything is an object, thus we do not define a data type for
variables when we declare them. See examples below;
#Declare PI constant and initialize to a value
PI = 3.1416
puts PI
#Declare my_string and initialize to a value
my_string = 'I love my city, New York'
puts my_string
$ global variable
@ instance variable
[az]
or _ local variable
[AZ]
constant
<Press any key to Go Back>
As it's shown in the sample output, first, a short description should be given. The description might
require more information. In case of above example, Ruby does not need data type declaration.
This is an important information needs to be put in your description.
For Selection Statements, use available statements as menu items. For example, if Selection
Statements and then Java selected, you should also show another menu with the following Items;
Java Selection Statements
Please select the statement type;
1. If
2. If Else
3. If ElseIf Else
4. Switch
5. <Go Back>
For Iterative Statements, a third level menu should list ALL available iterative statements in the
selected language. If the selected language is Java, then your menu would be;
Java Iterative Statements
Please select the statement type;
1. While
2. Do_While
3. For
4. For (Each)
5. <Go Back>
Test your application for every possible options. Write a report with a cover page, where you will
put only your source code. Then compress your report and application as one single file, submit
the compressed file.
Explanation / Answer
According to best of my knowledge within the given time,Iam giving the following code:
import java.util.Scanner;
public class Application
{
public static String selectedTopic(int choice)
{
String ch="Selected Topic=";
switch (choice)
{
case 1:
ch+=" Data Types";
break;
case 2:
ch+="Variable Declarations";break;
case 3:
ch+="Variable Initializations";
break;
case 4:
ch+="Assignment Statements";
break;
case 5:
ch+="Arithmetic Expressions";
break;
case 6:
ch+="Relational and Boolean Expressions";
break;
case 7:
ch+="Type Conversions";
break;
case 8:
ch+="Selection Statements";
break;
case 9:
ch+="Iterative Statements";
break;
case 10:
System.exit(0);
}
return ch;
}
public static String selectedLang(int choice)
{
String ch="";
switch (choice)
{
case 1:
ch+="Java";
break;
case 2:ch+="C";
break;
case 3:ch+="C++";
break;
case 4:ch+="C#";
break;
case 5:ch+="Python";
break;
case 6:ch+="JavaScript";
break;
case 7:ch+="PHP";
break;
case 8:ch+="Ruby";
break;
case 0:ch="GoBack";
}
return ch;
}
public static void main(String[] args)
{
int choice;String topic,lang,subch="";
Scanner s=new Scanner(System.in);
System.out.println("Select the topic you need help with; " +
"1. Data Types " +
"2. Variable Declarations " +
"3. Variable Initializations " +
"4. Assignment Statements " +
"5. Arithmetic Expressions " +
"6. Relational and Boolean Expressions " +
"7. Type Conversions " +
"8. Selection Statements " +
"9. Iterative Statements " +
"10. <QUIT>");
choice=s.nextInt();
topic=selectedTopic(choice);
System.out.println("Select the language for the topic <selected topic>. Enter 0 to Go Back; " +
"1. Java " +
"2. C " +
"3. C++ " +
"4. C# " +
"5. Python " +
"6. JavaScript " +
"7. PHP " +
"8. Ruby " +
"0. <Go Back>");
choice=s.nextInt();
if (choice==0)
{
System.out.println("Select the topic you need help with; " +
"1. Data Types " +
"2. Variable Declarations " +
"3. Variable Initializations " +
"4. Assignment Statements " +
"5. Arithmetic Expressions " +
"6. Relational and Boolean Expressions " +
"7. Type Conversions " +
"8. Selection Statements " +
"9. Iterative Statements " +
"10. <QUIT>");
choice=s.nextInt();
topic=selectedTopic(choice);
}
lang=selectedLang(choice);
if (choice==1)
{
System.out.println("Please select the statement type; " +
"1. If " +
"2. If Else " +
"3. If ElseIf Else " +
"4. Switch " +
"5. <Go Back>");
switch (s.nextInt())
{
case 1:
subch="If";
break;
case 2:subch="If Else";
break;
case 3:subch="If ElseIf Else";
break;
case 4:subch="Switch";
break;
case 5:subch="GoBack";
}
if (subch.equals("GoBack"))
{
System.out.println("Select the language for the topic <selected topic>. Enter 0 to Go Back; " +
"1. Java " +
"2. C " +
"3. C++ " +
"4. C# " +
"5. Python " +
"6. JavaScript " +
"7. PHP " +
"8. Ruby " +
"0. <Go Back>");
choice=s.nextInt();
if (choice==0)
{
System.out.println("Select the topic you need help with; " +
"1. Data Types " +
"2. Variable Declarations " +
"3. Variable Initializations " +
"4. Assignment Statements " +
"5. Arithmetic Expressions " +
"6. Relational and Boolean Expressions " +
"7. Type Conversions " +
"8. Selection Statements " +
"9. Iterative Statements " +
"10. <QUIT>");
choice=s.nextInt();
topic=selectedTopic(choice);
}
}
}
System.out.println(topic+lang);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.