2_ob85_meet
.docx
keyboard_arrow_up
School
Drexel University *
*We aren’t endorsed by this school
Course
431
Subject
Computer Science
Date
May 1, 2024
Type
docx
Pages
4
Uploaded by bbbtobi17 on coursehero.com
Tobi Bakare 04/13/2024
Week2Meet - 10 pts
===============================
Reading a program
Write pseudocode for the GenerateCode program.
/***************************************
* GenerateCode.java – name of the program * random passphrase program – the aim of the program
* * @author Tammy Pirmann – author * @version 1.0 – version of the coder
****************************************/
import java.util.Scanner; - importing class scanner used to get user input, import java.util.Random; - importing random generator
class GenerateCode { - - class name ( must be the same as the name of file)
public static void main (String args[]){- the main method used to run a program Random randGen = new Random(); - create a new random instance
Scanner keyboard = new Scanner(System.in); - create scanner object “keyboard” to read input
System.out.println("Welcome to the Code Generator! \n Answer some questions and I will generate a set of codes for your consideration."); -
print out the phrase System.out.println("The name of a loved one: "); -
print out the phrase String lovedOne = keyboard.next(); - asking for an input keyboard.nextLine(); - moving the input to the next line.
… ….
keyboard.close(); - close scanner object keyboard
int number = (randGen.nextInt(8))+2;
String shortFvrt = favorite.replace('a', ' '); -
replaces the
favorite food vowel with a space, in this case the vowel ‘a’
shortFvrt = shortFvrt.replace(" ", ""); - replaces the favorite food space with no space.
… ….
System.out.printf("Code #1: %s%d%s\n", lovedOne, year, shortFvrt); -
print out the random phrase in this order with three of the inputs
… ….
System.out.printf("Code #3: %s%d%s%d\n", lovedOne, number, place, year); - print out the random phrase in this order with four of the inputs
… ….
}
}
---------------------------------------------------------------------------------------------------------------------
------
I understand the problem introduced in class to be: (in your own words)
The problem introduced in class was aimed to generate random phrases from common words we like and know while also learning how to use int, replace and random number. This phrase could be useful in creating passwords also. My plan to solve this problem is: to get input for each part of the random phrase and put them together.
The solution to the problem was the following program: (provide the name of the .java file only)
GenerateCode.java
I tested the solution with at least 3 different value sets. The test data and results are:
(use this format: var1 = data, var2 = data, etc -> result)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
**************
The code provided to me when I asked this question is my own code from a preious question I asked on how to make it faster. My code is too slow and times out. I am looking for guidance on how to make it faster or a suggestion for a different approach. The question and my code are below.
**************
Question
Colour trio
def colour_trio(colours):
This problem was inspired by the fun little Mathologer video “Secret of Row 10” whose fractal animation once again remind us about how moving from two to three often opens the barn door for the chaos horse to emerge and wildly gallop away. To start, look at three values imaginatively named “red”, “yellow” and “blue”. These names serve as colourful (heh) mnemonics that could just as well have been “foo”, “bar” and “baz”, so no connection to actual physical colours is intended or implied. Next, de0ine a simple mixing rule between these colours with a rule that says that whenever any colour is mixed with itself, the result…
arrow_forward
Computer Science
MASM Assembly 8086
Write an program that will get the name and 1 number from a person. the output will double the number they have. you will get number and name twice
finally display the largest number with the name
example:
Please enter your name: TONY
Please enter your grade: 15
Tony, you got a 30
Please enter your name: April
Please enter your grade: 10
April, you got a 20
Finally display, Tony you got a 30
arrow_forward
USING FOR LOOP1. Create a program that can print 1to 50 .2. Create a program that can print 50-13. Print your name 10 times4. Print the output using for loop: 2 4 6 8 10 12 14 16 18 205. Print the output using for loop: 3 6 9 12 15 18 21
-USED JAVA PROGRAMMING LANGUAGE
arrow_forward
JAVA
The loop continuation condition is the inverse of the loop termination condition.
True
False
arrow_forward
Course Level Programming Assignment - Programming a Calculator using Python
In this assignment you will write a computer program from scratch using the Python programming language. This program will function as a simple calculator.
Objectives
• Write a simple Python program that performs arithmetic operations based on the user input
Stage 1: A simple calculator
Your calculator should provide the following arithmetic and control operations.
• Arithmetic Operations
• Addition (+)
add(a,b)
subtract(a,b)
• Subtraction (-)
• Multiplication (*)
• Division (/)
multiply(a,b)
divide(a,b)
power(a,b)
remainder(a,b)
• Power (^)
• Remainder (%)
• Control Operations
o Terminate (#)
o Reset ($)
Write a function select op(choice) to select the appropriate mathematics function based on the users selection.
The behavior of the program should be as follows:
You can start
• The program should ask the user to specify the desired operation…
arrow_forward
JAVA
Even if the condition is false at the first execution a while loop at least executes once.
True
False
A while loop can be used both as an event-controlled loop and as a count controlled loop.
True
False
arrow_forward
Please use while loop. this is for assembly language
arrow_forward
Looping is an essential component of any script or application written in Python. Looping allows you to run repeated operations without copying code. This Discussion Board is designed to help illustrate each loop type and when to use a particular loop type. Select either the For or While loop and provide the following in your Discussion Board post: A description of what the loop does An example of why you would use the loop you selected over the other Remember to use a reference to your learning materials or an outside source in at least one post each week.
arrow_forward
Counter controlled loops and flag while loops, instance methods and inner classes, shallow copying and deep copying are all words that are used in the Java programming language to describe various operations.
arrow_forward
Safari File Edit View History Bookmarks Window Help
= zyBooks
My library > CS 11: Introduction to Computer Science- C++ home >
1.19: LAB: Input and formatted output: Right-facing arrow
1.19 LAB: Input and formatted output: Right-facing arrow
Given two input integers for an arrow body and arrowhead (respectively), print a right-facing arrow.
Ex: If the input is:
01
the output is:
1
11
00000111
000001111
00000111
11
1
497630.3807866.qx3zqy7
LAB
ACTIVITY
learn.zybooks.com
1.19.1: LAB: Input and formatted output: Right-facing arrow
1 #include
2 using namespace std;
3
4 int main() {
5
6
7
8
9
10
11 }
int baseDigit;
int headDigit;
/* Type your code here. *,
return 0;
EzyBooks catalog
main.cpp
:i
0/10
((
Load default template...
Ơ
80
Fri Oct 13 3:27 AM
Help/FAQ kimberly sandoval
arrow_forward
Instruction: Create a notation resembling a simplified programming language with the input and output of a counting problem.
Write a program with the specified input and output:
Create a program for arithmetic sequence (initial value and common differenc
arrow_forward
recording or a file upload
Using an Arduino UNO or Arduino Nano, a breadboard, a 7-Segment Display, and the 4x4 keypad write a C program in
Microchip Studio that will do the following:
.
When a number is pressed on the keypad, display the corresponding number in the 7-Segment Display.
Blink the Decimal Point (DP) a specific number of times when each button of the letters are pressed.
For "A" blink 10 times, for "B" blink 11 times, for "C" blink 12 times, for "D" blink 13 times, for "*" blink once long
(1000ms), for "#" blink twice long (1000ms)
Use 4 10 pins on a single port for the column control
• Use 4 10 pins on a single port for the row control
. Do not use PORTDO or PORTD1
What to submit:
• A short video showing the functionality.
• Your C code as a "c" or "txt" file.
arrow_forward
True or False
1/ An arithmetic mean is an appropriate measure if the sum of all the measurements is a meaningful and interesting value.
2/ One of the benchmark principle is that it is a program written in a low-level language.
3/ Amdahl's law deals with the potential speedup of a program using multiple processors compared to a single processor.
arrow_forward
Н.W
1-Write microprocessor program using mnemonics to add two numbers 08 and 06.
2-Write the object code of the program.
3-Perform the program using STEP function.
4-Execute the program and write the results.
Object code
Mnemonics
A1
MOV AX
во
MOV AL
B3
MOV BL
04
ADD AL
F4
HLT
arrow_forward
. In debugging a program,
We are searching for availability of errors
We want to see whether a program executes with
A
errors
We want to prove that the program is working
without erors
We are correcting errors
arrow_forward
This question is in assembly language:
Code a Section of a Program
Code a loop that moves zeros to each byte of DATE_TBL
Question: DATE_TBL DB 25 DUP (?)
arrow_forward
All programming languages have a loop capability. Looping is the program logic’s ability to repeat one or more lines of code either:
A set number of times, a “for loop” (i.e. 10, 100, 500, 763 or more times)
An “unknown” number of times (i.e. loop terminates if a tested condition becomes “true” or as long as the tested condition remains “false”), a “while” loop, a “do until” loop, a “do while” loop.
This Lab exercise demonstrates the use of the “For Loop”, a standard loop in all programming languages. C++ standard For Loop format looks like:
For (n = 1; n <= 100; n++)
{
Loop line 1 code;
Loop line 2 code;
Loop line 3 code;
Loop line N code;
}
The loop code needs:
A “loop counter variable” (n in the above example) to keep track of how many iterations this loop has run
A starting value (i.e. 1 in the above example)
A stop test (i.e. run as…
arrow_forward
6. For & While Loops - Lab Programs
6.1 Write a Python Program to display the Multiplication Table of 12 or based on user
Input using for loop.
6.2 Write a Python Program to Print all Prime Numbers in an Interval
6.3 Write a Python Program to Find Armstrong Number in an Interval
6.4 Write a Python Program to find the Factorial of a Number
6.4 Write a Python Program to Print the Fibonacci Sequence...
NOTE
Do all the program
Take the screenshot of the program and the output
arrow_forward
Instruction: Create a notation resembling a simplified programming language with the input and output of a counting problem.
Write a program with the specified input and output:
Create a program for geometric sequence (initial value and common ratio)
arrow_forward
visual studio assembly language. ctt
6. Greatest Common Divisor (GCD)The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. The GCD algorithm involves integer division in a loop, described by the followingpseudocode:int GCD(int x, int y){ x = abs(x) // absolute value y = abs(y) do { int n = x % y x = y y = n } while (y > 0) return x}Implement this function in assembly language and write a test program that collects two numbers from the user and calls the function, passing it the two values. Display the result on the screen.
arrow_forward
• Write a program that asks the user to enter the size of a triangle (an integer from 1 to 10)
• Display the triangle by writing lines of asterisks
• The first line will have one asterisk, the next two, and so on, with each line having one more
asterisk than the last line up to the number entered by the user.
• On the following line, write one fewer asterisk and continue decreasing the number of
asterisks by 1 for each successive line until only one asterisk is displayed.
(Hint: Use nested for loops; the outside loop controls the number of lines to write, and the
inside loop controls the number of asterisks to display on a line.)
• For example, if the user enters 3, the output would be:
Input Data:
• An integer between 1 to 10
Set up an input validation loop to ensure the entered data is within range
• As long as the entered data is not within range, the user is to be prompted repeatedly until the
entered data is within range; at that point, then the valid input data is to be used to…
arrow_forward
Programming Language: Python
Topic: LOOPING
4. Write a program that will display the following pattern, given the value of n.
Example: If n= 4, output
****
***
**
*
arrow_forward
Determine the output of the following Pep/9 machine-language program when the input typed into the Pep/9 input window is 35
Remember: the left column only shows the memory address of the first byte on the line. Do not copy these memory addresses into the Pep/9 object code
window
0000 D1FC15
0003 F10013
0006 D1FC15
0009 F1FC16
000C D10013
000F F1FC16
0012 00
arrow_forward
computer programming
Loop is used to repeat a sequence of actions or statements many times. Simplydescribe the differences between for-loop and while-loop.
arrow_forward
Part 6: Boolean Logic Expressions
Boolean expressions are types of logical operations that we can perform on true and false values. Note that the word Boolean is always capitalized because it was named after its inventor, George Boole. Boolean algebra is a very important topic in computer science, and if you haven't learned it before you definitely will in the future. However, for our purposes we are only interested in how we can use them to manipulate binary numbers. The way we use them on binary numbers is by treating 1 as true and 0 as false. From this point on I will be using 0 and 1 instead of false and true.
There are many types of Boolean expressions, but the three most important ones are AND, OR, and NOT.
AND takes 2 operands and will output 1 if they are both 1, or 0 otherwise
OR takes 2 operands and will output 1 if either one is 1, or 0 if neither is 1
NOT takes 1 operand and reverses it: 1 becomes 0, and 0 becomes 1
We can represent this behavior using something called a…
arrow_forward
Associate each of the following concepts with one of the languages we covered (pseudo code, FORTRAN, Algol 60, Pascal, or Lisp). If the concept is closely associated with more than one language, choose the one that first introduced it in an important way. Explain your answer to each concept in the space to the right by defining/explaining the concept and providing some perspective about its value and use.
___________Do loop___________Weak Typing.
arrow_forward
Briefly explain the purpose for using selection statements in a Java program. Briefly explain a reason for using a while loop in a Java program.
arrow_forward
Please execute the program
arrow_forward
1. Write Pseudocode for adding two given numbers
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values for num1, num2.
Step 4: Calculate sum=num1+num2
Step 5: Display sum
Step 6: Stop
2. Write Pseudocode for multiplying two given numbers
Step 1: Start
Step 2: Declare variables num1, num2 and product.
Step 3: Read values for num1, num2.
Step 4: Calculate product=num1*num2
Step 5: Display product
Step 6: Stop
3. Write a Pseudocode that tells a user that the number they entered is not a 7 or a 9
Step 1: Start
Step 2: Declare and Read variable num.
Step 3: If num=7 then got to Step 3.1, Else go to Step 4
Step 3.1: Print “The number you entered is 7”
Step 4: Else if num=9 then go to Step 4.1, Else go to Step 5
Step 4.1: Print “The number you entered is 9”
Step 5: Print ”The number is not 7 or not 9”
Step 6: Stop
4. Write a Pseudocode to calculate the square and cube of a given number.
Step 1: Start
Step 2: Declare variables num,square,cube
Step 3: Calculate…
arrow_forward
subroutine
1. Write a program with a subroutine that takes three arguments, A, X, and Y. It then computes A*X*Y and returns it.
2. The main method, in a loop, prompts the user for values of A, X and Y and prints out the result.
code should be used in qtspim, also screenshot the output
arrow_forward
Uisng java Write a while loop to calculate the following sum: 1/2 + 2/3+ 3/4 +…….99/100
arrow_forward
C# programming.
Take input two integers n1 and n2 from the user and write a program to swap both the numbers and print them in the output.
Sample I/O:
Input the First Number : 5Input the Second Number : 6Expected Output:After Swapping :First Number : 6Second Number : 5
arrow_forward
// main module
Module main()
// Local variables
Declare Integer num1, num2, sum, answer
// Get numbers
Set num1 = random(1, 100)
Set num2 = random(1, 100)
Set sum = getSum(num1, num2)
// Get user answer
Call getAnswer(answer)
// display result
Call showResult(sum, answer)
End Module
// The getAnswer module gets user answer
Module getAnswer(Integer Ref inputAnswer)
Display “Enter sum of numbers: “
Input inputAnswer
End Module
// The showResult module tells if user answer is correct or not
Module showResult (Integer sum, answer)
If sum == answer Then
Display "Correct answer – Good Work!"
Else
Display "Correct answer is: ", sum
End If
End Module
// The getSum function adds 2 numbers.
Function Integer getSum(Integer num1, num2)
Declare Integer result
Set result = num1 + num2
Return result
flowchart for this please
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Related Questions
- ************** The code provided to me when I asked this question is my own code from a preious question I asked on how to make it faster. My code is too slow and times out. I am looking for guidance on how to make it faster or a suggestion for a different approach. The question and my code are below. ************** Question Colour trio def colour_trio(colours): This problem was inspired by the fun little Mathologer video “Secret of Row 10” whose fractal animation once again remind us about how moving from two to three often opens the barn door for the chaos horse to emerge and wildly gallop away. To start, look at three values imaginatively named “red”, “yellow” and “blue”. These names serve as colourful (heh) mnemonics that could just as well have been “foo”, “bar” and “baz”, so no connection to actual physical colours is intended or implied. Next, de0ine a simple mixing rule between these colours with a rule that says that whenever any colour is mixed with itself, the result…arrow_forwardComputer Science MASM Assembly 8086 Write an program that will get the name and 1 number from a person. the output will double the number they have. you will get number and name twice finally display the largest number with the name example: Please enter your name: TONY Please enter your grade: 15 Tony, you got a 30 Please enter your name: April Please enter your grade: 10 April, you got a 20 Finally display, Tony you got a 30arrow_forwardUSING FOR LOOP1. Create a program that can print 1to 50 .2. Create a program that can print 50-13. Print your name 10 times4. Print the output using for loop: 2 4 6 8 10 12 14 16 18 205. Print the output using for loop: 3 6 9 12 15 18 21 -USED JAVA PROGRAMMING LANGUAGEarrow_forward
- JAVA The loop continuation condition is the inverse of the loop termination condition. True Falsearrow_forwardCourse Level Programming Assignment - Programming a Calculator using Python In this assignment you will write a computer program from scratch using the Python programming language. This program will function as a simple calculator. Objectives • Write a simple Python program that performs arithmetic operations based on the user input Stage 1: A simple calculator Your calculator should provide the following arithmetic and control operations. • Arithmetic Operations • Addition (+) add(a,b) subtract(a,b) • Subtraction (-) • Multiplication (*) • Division (/) multiply(a,b) divide(a,b) power(a,b) remainder(a,b) • Power (^) • Remainder (%) • Control Operations o Terminate (#) o Reset ($) Write a function select op(choice) to select the appropriate mathematics function based on the users selection. The behavior of the program should be as follows: You can start • The program should ask the user to specify the desired operation…arrow_forwardJAVA Even if the condition is false at the first execution a while loop at least executes once. True False A while loop can be used both as an event-controlled loop and as a count controlled loop. True Falsearrow_forward
- Please use while loop. this is for assembly languagearrow_forwardLooping is an essential component of any script or application written in Python. Looping allows you to run repeated operations without copying code. This Discussion Board is designed to help illustrate each loop type and when to use a particular loop type. Select either the For or While loop and provide the following in your Discussion Board post: A description of what the loop does An example of why you would use the loop you selected over the other Remember to use a reference to your learning materials or an outside source in at least one post each week.arrow_forwardCounter controlled loops and flag while loops, instance methods and inner classes, shallow copying and deep copying are all words that are used in the Java programming language to describe various operations.arrow_forward
- Safari File Edit View History Bookmarks Window Help = zyBooks My library > CS 11: Introduction to Computer Science- C++ home > 1.19: LAB: Input and formatted output: Right-facing arrow 1.19 LAB: Input and formatted output: Right-facing arrow Given two input integers for an arrow body and arrowhead (respectively), print a right-facing arrow. Ex: If the input is: 01 the output is: 1 11 00000111 000001111 00000111 11 1 497630.3807866.qx3zqy7 LAB ACTIVITY learn.zybooks.com 1.19.1: LAB: Input and formatted output: Right-facing arrow 1 #include 2 using namespace std; 3 4 int main() { 5 6 7 8 9 10 11 } int baseDigit; int headDigit; /* Type your code here. *, return 0; EzyBooks catalog main.cpp :i 0/10 (( Load default template... Ơ 80 Fri Oct 13 3:27 AM Help/FAQ kimberly sandovalarrow_forwardInstruction: Create a notation resembling a simplified programming language with the input and output of a counting problem. Write a program with the specified input and output: Create a program for arithmetic sequence (initial value and common differencarrow_forwardrecording or a file upload Using an Arduino UNO or Arduino Nano, a breadboard, a 7-Segment Display, and the 4x4 keypad write a C program in Microchip Studio that will do the following: . When a number is pressed on the keypad, display the corresponding number in the 7-Segment Display. Blink the Decimal Point (DP) a specific number of times when each button of the letters are pressed. For "A" blink 10 times, for "B" blink 11 times, for "C" blink 12 times, for "D" blink 13 times, for "*" blink once long (1000ms), for "#" blink twice long (1000ms) Use 4 10 pins on a single port for the column control • Use 4 10 pins on a single port for the row control . Do not use PORTDO or PORTD1 What to submit: • A short video showing the functionality. • Your C code as a "c" or "txt" file.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning