Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
14 views19 pages

Computing and Software Engineering GET 200 Answer Guide

Uploaded by

ELIAS TIOLUWANI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views19 pages

Computing and Software Engineering GET 200 Answer Guide

Uploaded by

ELIAS TIOLUWANI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

GET 200

ANSWER GUIDE
1. Define a comuter system?
A comuter system is a basic and functional comuter that includes all the hardware and software that are
required to make it functional for the user
1b.

1c. Explain Cathode ray tube (CRT) technology


CRT stands for Cathode Ray Tube. CRT is a technology used in traditional computer monitors and
televisions. The image on CRT display is created by firing electrons from the back of the tube of phosphorus
located towards the front of the screen.

Once the electron heats the phosphorus, they light up, and they are projected on a screen. The color you
view on the screen is produced by a blend of red, blue and green light

1d. Write a Java program to find the square root of a number using the Babylonian method.

2.) With the aid of suitable schematic diagram explain the function of the following
computer hardware components (i) CPU, (ii) main memory (RAM), (iii) hard disk, (iv)
display unit, (iv) main/mother board, (vi) CMOS battery, (vii) Keyboard (vii) Mouse
I) CPU: The CPU is the brain of the computer, responsible for executing instructions from programs. It
performs arithmetic and logical operations, controls data flow between components, and manages tasks
via its Control Unit (CU) and Arithmetic Logic Unit (ALU).

Ii) Main memory:RAM (Random Access Memory) temporarily stores data and instructions that the CPU
needs during operation. It is volatile, meaning it loses data when power is off.

iii) hard disk: The hard disk is a non-volatile storage device used to store operating systems, applications,
and user data. Data is written magnetically onto spinning platters.

(iv) display unit: The display unit (monitor) provides a visual interface for users to interact with the
computer, displaying output from the CPU as text, images, or videos.

(iv) main/mother board; The motherboard is the central circuit board that connects all components, such
as the CPU, RAM, storage, and peripheral devices, enabling communication and power distribution.
(vi) CMOS battery; The CMOS battery powers the BIOS firmware that stores system settings like date, time,
and hardware configuration, even when the computer is off.

(vii) Keyboard; The keyboard is an input device used to enter text and commands into the computer. It
translates keystrokes into signals that the CPU processes.

(vii) Mouse; The mouse is a pointing device that allows users to interact with the graphical user interface
(GUI) by moving a cursor on the screen and performing actions like clicking and scrolling.

2c. Write a Java program to get a number from the user and print whether it is positive or
negative.
import java.util.Scanner;
public class Exercise1 {

public static void main(String[] args)


{
Scanner in = new Scanner(System.in);
System.out.print("Input number: ");
int input = in.nextInt();

if (input > 0)
{
System.out.println("Number is positive");
}
else if (input < 0)
{
System.out.println("Number is negative");
}
else
{
System.out.println("Number is zero");
}
}
}
3a. Define software.
Software refers to a set of instructions, data, or programs used to operate computers and execute specific
tasks. It is intangible and contrasts with physical hardware. Software enables users to interact with the
hardware and perform computational or operational tasks.
b) Differentiate between system software and application software.
System Software Application Software
System Software maintains the system resources Application software is built for specific tasks.
and gives the path for application software to run.
Low-level languages are used to write the system While high-level languages are used to write the
software. application software.
It is general-purpose software. While it’s a specific purpose software.
Without system software, the system stops and While Without application software system always
can’t run. runs.

c) Write a Java program that takes three numbers from the user and prints the greatest
number.
import java.util.Scanner;
public class Exercise3 {

public static void main(String[] args) {


Scanner in = new Scanner(System.in);

System.out.print("Input the 1st number: ");


int num1 = in.nextInt();

System.out.print("Input the 2nd number: ");


int num2 = in.nextInt();

System.out.print("Input the 3rd number: ");


int num3 = in.nextInt();
if (num1 > num2)
if (num1 > num3)
System.out.println("The greatest: " + num1);

if (num2 > num1)


if (num2 > num3)
System.out.println("The greatest: " + num2);

if (num3 > num1)


if (num3 > num2)
System.out.println("The greatest: " + num3);
}
}
4a) What is Computer program.
A computer program is a set of instructions written in a specific programming language to perform a
particular task or solve a problem. These instructions are executed by the computer's hardware to achieve
desired outputs. Programs can be written in various languages such as Python, Java, or C++ and are
classified as software.
b) Highlight features of a good program:
1. Probability
2. Readability
3.Efficency
4. structural
5. Flexibility
6.Generality
7.Userability
8. Documentation
c) Explain Machine Language, Assembly Language and High Level Language.
a.Machine Language:
Machine language consists of binary code (0s and 1s) that the computer's CPU can directly understand and
execute. It is the most basic and fundamental level of programming language.
b.Assembly Language:
Assembly language is a low-level programming language that uses mnemonics (human-readable
instructions like MOV, ADD, SUB) instead of binary code. These instructions are specific to a particular CPU
architecture and are translated into machine language using an assembler.
c.High-Level Language:
High-level languages are programming languages that are closer to human language and abstract away
hardware details. Examples include Python, Java, C++, and JavaScript. They require a compiler or
interpreter to convert them into machine language.

D.Write a Java program to display the pattern like a right angle triangle with a number as
shown below.

import java.util.Scanner;
public class Exercise16 {

public static void main(String[] args)

{
int i,j,n;
System.out.print("Input number of rows : ");
Scanner in = new Scanner(System.in);
n = in.nextInt();

for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
System.out.print(j);

System.out.println("");
}
}
}
QUESTION 5
a) Define algorithm
An algorithm is a set of defined steps designed to perform a specific objective

b) Highlight the feature of an Algorithm


1. Finiteness
2. Effectiveness
3. Defniteness

c) Write a Java program to display the pattern like a diamond.


import java.util.Scanner;
public class Exercise21 {

public static void main(String[] args)

{
int i,j,r;
System.out.print("Input number of rows (half of the diamond) : ");
Scanner in = new Scanner(System.in);
r = in.nextInt();
for(i=0;i<=r;i++)
{
for(j=1;j<=r-i;j++)
System.out.print(" ");
for(j=1;j<=2*i-1;j++)
System.out.print("*");
System.out.print("\n");
}

for(i=r-1;i>=1;i--)
{
for(j=1;j<=r-i;j++)
System.out.print(" ");
for(j=1;j<=2*i-1;j++)
System.out.print("*");
System.out.print("\n");
}

}
}
QUESTION 6
a) Define flowchart
A flowchart is a graphical representation of a process, system, or algorithm. It uses symbols, shapes, and
arrows to depict the sequence of steps and the flow of control in solving a problem or performing a task.
Flowcharts help visualize the structure of a process, making it easier to understand, analyze, and
communicate.

b) In tabular form write name, usage and draw the shapes of Flowchart Symbols.

c) Write a Java program that accepts three numbers and prints "All numbers are equal" if all
three numbers are equal, "All numbers are different" if all three numbers are different and
"Neither all are equal or different" otherwise.

import java.util.Scanner;
public class Exercise30 {

public static void main(String[] args)


{
Scanner in = new Scanner(System.in);

System.out.print("Input first number: ");


int x = in.nextInt();
System.out.print("Input second number: ");
int y = in.nextInt();
System.out.print("Input third number: ");
int z = in.nextInt();

if (x == y && x == z)
{
System.out.println("All numbers are equal");
}
else if ((x == y) || (x == z) || (z == y))
{
System.out.println("Neither all are equal or different");
}
else
{
System.out.println("All numbers are different");
}
}
}
7a) Define Modular Programming.
Modular Programming is a software design technique that involves breaking down a program into smaller,
independent, and reusable modules or functions. Each module is responsible for a specific task or
functionality, making the program easier to develop, test, maintain, and debug.

B)State and explain the advantages of Modular Programming.

c) All 200 level in the Faculty of Engineering and Technology were asked to register for ID
Card at the senate building. Develop an application to inform the students and print “YOU
ARE WELCOME PLEASE REGISTER” if the student is in 200 level, or print “YOU ARE
NOT IN 200 LEVEL” otherwise.

import java.util.Scanner;

public class StudentRegistration {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// Input: Student's level


System.out.print("Enter your level: ");
int studentLevel = scanner.nextInt();

// Check if the student is in 200 level


if (studentLevel == 200) {
System.out.println("YOU ARE WELCOME. PLEASE REGISTER.");
} else {
System.out.println("YOU ARE NOT IN 200 LEVEL.");
}

scanner.close();
}
}

8a) Describe Variable as it relates to computer programming.


A variable in computer programming is a named storage location in memory that holds data that can be
changed or updated during program execution. Variables are used to store values such as numbers,
characters, or strings, which can be manipulated by the program.
b) State rules of naming variables in Java,
 A variable name can consist of Capital letters A-Z, lowercase letters a-z digits 0-9, and two special
characters such as _ underscore and $ dollar sign.
 The first character must not be a digit.
 Blank spaces cannot be used in variable names.
 Java keywords cannot be used as variable names.
 Variable names are case-sensitive.
 There is no limit on the length of a variable name but by convention, it should be between 4 to 15
chars.
 Variable names always should exist on the left-hand side of assignment operators.
c) List 14 reserved words in Java. compound names.

1. abstract
2. boolean
3. byte
4. class
5. double
6. extends
7. final
8. import
9. int
10. new
11. private
12. public
13. return
14. static

c) Write a Java program to get whole and fractional parts from a double value

import java.util.*;
public class Example2 {
public static void main(String[] args) {
double value = 12.56;
double fractional_part = value % 1;
double integral_part = value - fractional_part;
System.out.print("\nOriginal value: "+value);
System.out.print("\nIntegral part: "+integral_part);
System.out.print("\nFractional part: "+fractional_part);
System.out.println();
}
}

9a) With example explain the concept of Compound and Non-compound names
Non-Compound Names:
These are single-word names used to identify variables, classes, methods, or objects in a program. They are
simple and straightforward.
E.G int age = 25;
String name = "John";

Compound Names:
These consist of multiple words combined to form a meaningful identifier. In Java, the camelCase
convention is typically used for variable and method names, while PascalCase is used for class names.
Example:
int totalMarks = 85;
String firstName = "Emily";

b) List and describe briefly the primitive types available in Java.


1. Boolean Data Type
A boolean data type can have two types of values, which are true and false. It is used to add a simple flag
that displays true/false conditions. It represents one bit of information. It's is not a specific size data type.
So, we can not precisely define its size.

2) Byte Data Type


It is an 8-bit signed 2's complement integer. It can have a value of (-128) to 127 ( inclusive). Below are the
benefits of using the byte data type:

It is useful for saving memory in large Arrays.


It can be used instead of int to clarify our code using its limits.
It saves memory, too, because it is 4 times smaller than an integer.

3) Int Data Type


The int stands for Integer; it is a 32-bit signed two's complement integer. It's value can be from -2^31 to
(2^31-1), which is -32,768 to 32,767 (inclusive). Its default value is zero. It represents an unsigned 32-bit
integer, which has a value range from 0 to 32,767.

4) Long Data Type


It is a 64-bit 2's complement integer with a value range of (-2^63) to (2^63 -1) inclusive. It is used for the
higher values that can not be handled by the int data type.

5) Float Data Type


The Float data type is used to declare the floating values ( fractional numbers). It is a single-precision 32-bit
IEEE 754 floating-point data type.

6) Double Data Type


The double data type is also used for the floating-point ( Fractional values) number. It is much similar to
the float data type. But, generally, it is used for decimal values. Like the float data type, its value range is
infinite and also can not be used for precise values such as currency.
7) Char Data Type
The default value of the double data type is 0.0d. While declaring the double type values, we must end the
value with a d.

The char data type is also an essential primitive data type in Java. It is used to declare the character values.
It is a single 16-bit Unicode Character with a value range of 0 to 65,535 (inclusive).

While declaring a character variable, its value must be surrounded by a single quote ('').

8) Short Data Type


The short data type is also used to store the integer values. It is a 16-bit signed 2's complement integer
with a value range of -32,768 to 32,767 (inclusive). It is also used to save memory, just like the byte data
type.

It is recommended to use the short data type in a large array when memory saving is essential.
c)s Describe Increment operators, Decrement operators and relational operator
Increment Operators
Increment operators are used to increase the value of a variable by 1. They come in two forms:

Pre-increment (++var)

The variable is incremented before it is used in the expression.

Post-increment (var++)

The variable is incremented after it is used in the expression.

Decrement Operators
Decrement operators are used to decrease the value of a variable by 1. They also have two forms:

Pre-decrement (--var)

The variable is decremented before it is used in the expression.

Post-decrement (var--)

The variable is decremented after it is used in the expression.

Relational Operators
Relational operators are used to compare two values or expressions. The result of these comparisons is
always a boolean value (true or false).

10a) What is a block statement? How are block statements used in Java programs.
A block statement is a sequence of zero or more statements enclosed in braces {}. It is used to group
multiple statements together so that they can be treated as a single statement. This is particularly useful in
control flow statements like if...else, for, and while loops, where only one statement is expected 12
 To Define the Scope of Variables
 In Conditional Statements
 In loops
 in methods definition
 As Anonymous Blocks
b) What is the main difference between a while loop and a do ...while loop?
The while loop is the most basic looping structure used in programming and is used where the number of
iterations are unknown. The while loop is used to execute a block of code until the condition is true,
meaning the loop keeps running until the required condition is met. The do-while loop is very similar to the
while loop except it performs the statements inside the loop exactly once before evaluating the condition
of the loop and it runs at least once, regardless of whether the condition is met.

c) Write a for loop that will print out all the multiples of 3 from 3 to 36, that is: 3 6 9 12 15
18 21 24 27 30 33 36.

for ( N = 3; N <= 36; N++ ) {


if ( N % 3 == 0 )
System.out.println( N );
}}
11a) Fill in the following main() routine so that it will ask the user to enter an integer, read the
user’s response, and tell the user whether the number entered is even or odd. (You can use
TextIO.getInt() to read the integer. Recall that an integer n is even if n % 2 == 0.) public
static void main(String[] args) { // Fill in the body of this subroutine! }

pubimport java.util.Scanner;

public class EvenOrOdd {


public static void main (String[] args) {

int n; // the number read from the user

TextIO.put("Type an integer: "); // ask the use to enter an integer

n = TextIO.getInt(); // read the user's response

if (n % 2 == 0) // tell the user whether the number is even or odd


System.out.println("That's an even number.");
else
System.out.println("That's an odd number.");
}

b) Draw flowchart to solve the problem describe in 11a.

c) Explain the concept of JDK and JVM


Java Development Kit (JDK):
Definition:
The JDK is a comprehensive software development environment used for creating, debugging, and running
Java applications. It is the primary tool for developers to build Java programs.
Java Virtual Machine (JVM):
Definition:
The JVM is a runtime environment responsible for executing Java bytecode, making Java applications
platform-independent.

Question 12
a) Show the exact output that would be produced by the following main() routine:
public static void main(String[] args) {
int N;
N = 1;
while (N <= 32) {
N = 2 * N;
8
System.out.println(N);
}
}

The exact output printed by this program is:

2
4
8
16
32
64
b) Show the exact output produced by the following main() routine:
public static void main(String[] args) {
int x,y;
x = 5;
y = 1;
while (x > 0) {
x = x - 1;
y = y * x;
System.out.println(y);
}
}

value of x | value of y OUTPUT


--------------|-------------- -------------
5 | 1 [ before loop]
4 | 4 [ = 1*4 ] 4
3 | 12 [ = 4*3 ] 12
2 | 24 [ = 12*2 ] 24
1 | 24 [ = 24*1 ] 24
0 | 0 [ = 24*0 ] 0
d) Explain the Baseline Technologies of IoT

IoT stands for Internet of Things. It refers to the interconnectedness of physical devices, such as appliances
and vehicles, that are embedded with software, sensors, and connectivity which enables these objects to
connect and exchange data. This technology allows for the collection and sharing of data from a vast
network of devices, creating opportunities for more efficient and automated systems.

Internet of Things (IoT) is the networking of physical objects that contain electronics embedded within
their architecture in order to communicate and sense interactions amongst each other or with respect to
the external environment. In the upcoming years, IoT-based technology will offer advanced levels of
services and practically change the way people lead their daily lives. Advancements in medicine, power,
gene therapies, agriculture, smart cities, and smart homes are just a few of the categorical examples where
IoT is strongly established.
Question 13
a) Write a program that asks the user’s name, and then greets the user by name. Before
outputting the user’s name, convert it to upper case letters. For example, if the user’s name
is Fred, then the program should respond “Hello, FRED, nice to meet you!”.

/* This program asks the user's name and then


greets the user by name. This program depends
on the non-standard class, TextIO.
*/

public static void main(String[] args) {

String usersName; // The user's name, as entered by the user.


String upperCaseName; // The user's name, converted to uppercase letters.

TextIO.put("Please enter your name: ");


usersName = TextIO.getln();

upperCaseName = usersName.toUpperCase();

TextIO.putln("Hello, " + upperCaseName + ", nice to meet you!");

} // end main()

} // end class

b) Write a pseudocode to design the computational problem in


BEGIN
PROMPT the user to enter their name
READ the user’s input as "name"
CONVERT "name" to uppercase and STORE it as "upperName"
DISPLAY the message: "Hello, [upperName], nice to meet you!"
END

c) Describe methods of expressing algorithm.


Natural Language
Pseudocode
Flowchart
Control Table
Drakon charts

Question 14
a) Supposed as an Engineer, you are being contacted by INEC to develop an application for
voting in Nigeria. Write a Java program to solve the problem.
import java.util.Scanner;

public class VotingApplication {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Welcome to INEC Voting System");


System.out.println("Enter your Voter Identification Number (VIN):");
String vin = scanner.nextLine();

// Simple check for voter validation


if (vin.length() == 11) { // Assuming VIN has 11 characters
System.out.println("You are a verified voter.");
System.out.println("Please select your candidate:");
System.out.println("1. Candidate A");
System.out.println("2. Candidate B");
System.out.println("3. Candidate C");
int choice = scanner.nextInt();

switch (choice) {
case 1:
System.out.println("You voted for Candidate A.");
break;
case 2:
System.out.println("You voted for Candidate B.");
break;
case 3:
System.out.println("You voted for Candidate C.");
break;
default:
System.out.println("Invalid choice. Vote not recorded.");
break;
}
} else {
System.out.println("Invalid VIN. You are not eligible to vote.");
}

System.out.println("Thank you for using the INEC Voting System.");


scanner.close();
}
}

b) Draw a flowchart of the problem solved in 14a.

c) Describe Intel’s Pentium processor.


Intel’s Pentium processor was first introduced in 1993 as a successor to the Intel 80486 microprocessor. It
marked a significant advancement in microprocessor technology and architecture, providing enhanced
performance, higher clock speeds, and advanced features.

Key Features:
Superscalar Architecture:
Integrated Floating Point Unit (FPU):
64-bit Data Bus:
Multiple Clock Speeds:

Question 15
a) Define IoT.
The internet of things, or IoT, is a network of interrelated devices that connect and exchange data with
other IoT devices and the cloud. IoT devices are typically embedded with technology such as sensors and
software and can include mechanical and digital machines and consumer objects.

b) State the Characteristics of IoT.


1.Connectivity
2.Intelligence and Identity
3. Scalability
4. Dynamic and Self-Adapting (Complexity)
5. Architecture
6. Safety
7. Self Configuring
8. Interoperability

c) Highlight the Applications Of IoT. Challenges of IoT.


(c) Applications of IoT
Smart Homes:
Healthcare:
Industrial Automation:
Agriculture:
Transportation:
Retail:
Environment:
Challenges
Security Risks:
Interoperability:
Data Privacy:
Energy Constraints:
Network Issues:
Cost: High
d) Write a Java program to convert a Roman number to an integer number
public class Example7 {
public static void main(String[] args) {
String str = "DCCVII";
int len = str.length();

str = str + " ";


int result = 0;
for (int i = 0; i < len; i++) {
char ch = str.charAt(i);
char next_char = str.charAt(i+1);

if (ch == 'M') {
result += 1000;
} else if (ch == 'C') {
if (next_char == 'M') {
result += 900;
i++;
} else if (next_char == 'D') {
result += 400;
i++;
} else {
result += 100;
}
} else if (ch == 'D') {
result += 500;
} else if (ch == 'X') {
if (next_char == 'C') {
result += 90;
i++;
} else if (next_char == 'L') {
result += 40;
i++;
} else {
result += 10;
}
} else if (ch == 'L') {
result += 50;
} else if (ch == 'I') {
if (next_char == 'X') {
result += 9;
i++;
} else if (next_char == 'V') {
result += 4;
i++;
} else {
result++;
}
} else { // if (ch == 'V')
result += 5;
}
}
System.out.println("\nRoman Number: "+str);
System.out.println("Equivalent Integer: "+result+"\n");
}
}
Question 16
a) Defines software engineering.
Software Engineering is a disciplined and systematic approach to designing, developing, testing, and
maintaining software by applying engineering principles. It aims to deliver high-quality software
efficiently and cost-effectively while meeting user requirements.

b) Explain why we need of Software Engineering.


 Handling Big Projects
 To manage the cost
 To decrease time
 Reliable software
 Effectiveness
 Reduces complexity:
 Productivity
c) Write a Java program to test if a double number is an integer
import java.util.*;
public class Example3 {
public static void main(String[] args) {
double d_num = 5.44444;
if ((d_num % 1) == 0) {
System.out.println("It's not a double number");
} else {
System.out.println("It's a double number");
}
}
}

Question 17
**********
**********
**********
**********
**********
a) Develop a java application to print out the above figure and inform the user about its
dimension.

public class PrintFigure {


public static void main(String[] args) {
int rows = 5, cols = 9;

// Print the first row with '9' at the center


for (int i = 0; i < cols; i++) {
if (i == cols / 2) {
System.out.print("9");
} else {
System.out.print("*");
}
}
System.out.println();

// Print the remaining rows with all '*'


for (int i = 1; i < rows; i++) {
for (int j = 0; j < cols; j++) {
System.out.print("*");
}
System.out.println();
}

// Inform the user about the figure's dimensions


System.out.println("The dimensions of the figure are " + rows + " rows and " + cols + " columns.");
}
}

b) Write a Java program to calculate the root of a quadratic equation using the general
quadratic equation and taking into consideration the real and equal root and imaginary root.
import java.util.Scanner;

public class QuadraticEquation {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.print("Enter coefficient a: ");


double a = scanner.nextDouble();

System.out.print("Enter coefficient b: ");


double b = scanner.nextDouble();

System.out.print("Enter coefficient c: ");


double c = scanner.nextDouble();

// Calculate the discriminant


double discriminant = b * b - 4 * a * c;

if (discriminant > 0) {
// Two real and distinct roots
double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
System.out.println("The roots are real and distinct.");
System.out.println("Root 1: " + root1);
System.out.println("Root 2: " + root2);
} else if (discriminant == 0) {
// One real and equal root
double root = -b / (2 * a);
System.out.println("The roots are real and equal.");
System.out.println("Root: " + root);
} else {
// Imaginary roots
double realPart = -b / (2 * a);
double imaginaryPart = Math.sqrt(-discriminant) / (2 * a);
System.out.println("The roots are imaginary.");
System.out.println("Root 1: " + realPart + " + " + imaginaryPart + "i");
System.out.println("Root 2: " + realPart + " - " + imaginaryPart + "i");
}

scanner.close();
}
}

d) Describe some software life cycle model


1. RAD model
2. iterative model
3. V-Model
4. Inxcremental model
5. Waterrfall model

OMO!!!!! I WISH YOU ALL SUCCESS.

You might also like