Ch 4 Program 4A: Factorial.java
Please adhere to the Standards for Programming Assignments and the Java Coding Guidelines.
Write a program that computes the factorial of a number that is
input from the user.
A factorial is the product of all the numbers up to the number entered.
For example, 6-factorial is 720 because 6*5*4*3*2*1 is 720.
Six-factorial is written as 6!
Prompt the user for the numeric input between 1 and 10.
Do not accept numbers greater than 10 or less than 1.( Check out the input/data Validation page on Canvas in module 4B)
Calculate and display the factorial. All code must reside in the main() method
Do not use any concept that is not covered in class.
Include output from this Test Data: 22
7
1
Example Output with Valid inputs: *******Factorial********* Please enter a value between 1-10: 5 5! = 120 Goodbye!! Example Output with an Invalid input: *******Factorial********* Please enter a value between 1-10: 12 Value is out of range. Please Re-enter a value between 1-10 : 17 Value is out of range. Please Re-enter a value between 1-10 : 8 8! = 40320 Goodbye!! |
In: Computer Science
Discuss the type of noise that is the most difficult to remove from an analog and a digital signal? Give reasons for your answer. How does error detection and correction work with wireless signals? Is data compressed when being transmitted? Describe the process.
In: Computer Science
Describe how component-based development is used during the requirements gathering and definition within the Agile process (software engineering).
In: Computer Science
in java
Write a program that convert a Fahrenheit to Celsius. For conversion, use as many as methods you want
In: Computer Science
Later you will be making a logo for your project website. For now, you are going to style a photograph for your project.
Choose at an appropriate picture from one of these sources:
Save your original photograph with the names of original.psd and original. jpg before you modify it.
Then use "save as" to create another copy of your photograph and modify it using at least TWO techniques covered so far. You may do more if you wish.
Integrate your final photograph into your Dreamweaver website.
Turn in the following:
1. Both the original and modified photographs in a zipped file that you upload here, four files total. (60 points)
2. In your submission comments, provide the URL of your webpage where you have put the file on MyDrive. Your graphic should be in a separate folder for graphics, and your image and web page should render properly. If your graphic doesn't appear, check the reference. (30 points)
3. AND, also in the submission comments, describe the modifications you made to your photograph. (10 points)
In: Computer Science
Andrea Stevens Cosmetics is a small cosmetics company that has a network of 30 computers. They are currently using a 100BaseT network that is wired with Category 6 Plenum cable. Their computers were purchased six years ago as a single buy from Dell. The computers have single Intel i3 processors, 2 GB RAM, and 500 GB hard drives. Their network has two 24 port hubs and a gateway router that connects them to a Cox cable modem. Most of their computers are used for order processing and inventory control. The computers are arranged in a workgroup called ASC, with all hard drives and printers shared. The manufacturing plant has computerized equipment that is on a separate network that is self-contained and isolated. You are hired as a consultant to bring their network into the 21st century. Based on your knowledge, experience, and what you have read in this week's assignment, propose an upgrade to this architecture. Describe the components you would recommend and how the network would be configured. Your goal should be a network that will support them for the next five years. Because the information in this mini-case is limited, you will have to make some assumptions. Be sure to document any assumptions that you make.
In: Computer Science
Write a C program that reads three integers and then prints them in the order read and reversed. Use four functions: main, one to read the data, one to print them in the order read, and one to print them reversed.
In: Computer Science
Someone once said, "if you gave everyone in the world a million dollars and if you waited long enough then 1 person would have all the money and everyone else would have nothing". You are going to write a program to test truthfullness of that statement.
Repeat the following actions until nActive equals 1:
using this code
#include "fixed1dintarray.h"
fixed1dintarray::fixed1dintarray(int newnelts)
{
if (newnelts < 2)
newnelts = 16;
size = newnelts;
nelts = 0;
elts = new int[size];
}
bool fixed1dintarray::isEmpty()
{
return nelts == 0;
}
bool fixed1dintarray::isFull()
{
return nelts == size;
}
int fixed1dintarray::getsize()
{
return size;
}
int fixed1dintarray::getnelts()
{
return nelts;
}
bool fixed1dintarray::getelt(int where, int& elt)
{
bool isgood = 0 <= where && where < nelts;
if (isgood)
elt = elts[where];
return isgood;
}
bool fixed1dintarray::member(int value)
{
return find(value) >= 0;
}
int fixed1dintarray::find(int value)
{
int pos = 0;
//while(!(pos < nelts || elts[pos] == value))
//until(pos == nelts || elts[pos] == value)
while (pos < nelts && elts[pos] != value)
pos++;
if (pos < nelts)
return pos;
else
return -1;
}
bool fixed1dintarray::insat(int where, int elt)
{
if (isFull())
return false;
if (where < 0 || nelts < where)
return false;
for (int pos = nelts - 1; pos >= where; pos--)
elts[pos + 1] = elts[pos];
elts[where] = elt;
nelts++;
return true;
}
bool fixed1dintarray::append(int elt)
{
return insat(nelts, elt);
}
bool fixed1dintarray::delat(int where)
{
if (where < 0 || nelts <= where)
return false;
for (int pos = where + 1; pos < nelts; pos++)
elts[pos - 1] = elts[pos];
return false;
}
bool fixed1dintarray::delelt(int elt)
{
int where = find(elt);
return delat(where);
}
void fixed1dintarray::show()
{
for (int i = 0; i < nelts; i++)
cout << elts[i] << ' ';
}
In: Computer Science
Write a program that asks a user how many classes they are taking this term, the name of each class, the credit hours for each class, and their final letter grade for each class, and then calculates their term GPA. Use either a list for each course or a single list-of-lists. The grading system and examples can be found on the TAMU website: http://registrar.tamu.edu/Transcripts-Grades/How-to-Calculate-GPA
In: Computer Science
Writing a caesar cipher in ARM assembly.
INSTRUCTIONS:
Step 1: The first thing you should do is modify the case conversion program String.s (provided) Instead of subtracting 32 from all numbers you want to add a constant number which we will call the key. Assume that all input will be lowercase. So it'll look like this, k = 2; letter = 'a'; newletter = k+letter; Above is pseudocode and ABOVE NOT ASSEMBLY CODE DO NOT COPY. Use bl puts to show that everything is working correctly. You should hard code the plaintext in the assembly file. Step 2: If the key + letter is bigger is 'z' then you have to subtract 26. If the key + letter is less than 'a' then you have to add 26.
STRING.S
.text .global main main: ldr r4,=string get_another_byte: ldrb r5,[r4] cmp r5,#'a' # blt keep_going # cmp r5,#'z' # bgt keep_going subeq r5,#32 strbge r5,[r4] keep_going: add r4,#1 cmp r5,#0 bne get_another_byte ldr r0,=temp str lr,[r0] ldr r0,=string bl puts ldr r0,=temp ldr lr,[r0] bx lr .data string: .asciz "This is a string" temp: .word 0
In: Computer Science
import java.util.*;
import java.security.*;
import javax.crypto.*;
import java.nio.file.*;
public class CryptoApp {
public static void main(String[] args) throws Exception {
Crypto crypto = new BasicCrypto();
String welcome = "Hello
2043-er's! Let's try this again :-)";
System.out.println(welcome);
// First, where are we?
//Let's print out our current working directory
Path cwd =
FileSystems.getDefault().getPath("").toAbsolutePath();
System.out.println("Current Working Directory: " + cwd);
// Read in our file to encrypt
byte[] originalData =
Files.readAllBytes(Paths.get(System.getProperty("user.home"),
"C-2044-Sample/Crypto/src/encrypt.txt"));
// Encrypt it and save into a byte array
byte[] encryptedData = crypto.encrypt(originalData);
// Decrypt it and save it into
another byte array
byte[] decryptedData = crypto.decrypt(encryptedData);
// Write the encrypted text into the original file
Files.write(Paths.get(System.getProperty("user.home"), "test"),
encryptedData);
// Write the decrypted text into the decrypted text file
Files.write(Paths.get(System.getProperty("user.home"),
"C-2044-Sample/Crypto/src/decrypt.txt"), decryptedData);
String sendoff = "It's a wrap!";
System.out.println(sendoff);
}
}
Ok so for this code I changed the name of the file from java-2022 to C-2044 to intentionally create an exception.
Exception in thread "main" java.nio.file.NoSuchFileException: /home/runner/C-2044-Sample/Crypto/src/encrypt.txt
so how would I write a try/catch/finally cause to catch one or more specific exception objects.
In: Computer Science
In C programming. If a grammatically correct input is entered,
the program should convert the two
strings to two integer arrays and perform the given operation on
each array location.
For all operations, consider each corresponding array position
independently (e.g.,
there are no carries). The resulting array should then be converted
back to a string,
and finally printed. If the two input strings are not the same
length, then each output
character beyond the length of the shorter string should be a copy
of the character
from the longer string with the opposite case.
The mathematical operations work as follows. Each symbol should be
converted to
an integer as shown in the table to the right (i.e., a is 0, b is
1, c is 2, …, U is 46).
This mapping forms a finite field, and we can define addition and
multiplication on
this field.
Symbol Value
a 0
b 1
... ...
z 25
A 26
B 27
... ...
T 45
U 46
Page 2 of 3
Addition on a finite field: +
For this operation, for each array position find the sum of the two
integers and if the result is larger than
46 find the remainder when the quotient is 47. That is, find (? +
?) ??? 47. For example, if the user
enters:
> abc+bbc
the result that should be printed is
'abc' + 'bbc' => 'bce'
> tuvwx+CBAzy
'tuvwx' + 'CBAzy' => 'aaaaa'
For this example the first string is longer than the second (the
'e' in orange). The output corresponding
to this extra symbol is 'E':
> orange+white
'orange' + 'white' => 'KyiGkE'
Multiplication on a finite field: *
This operation is handled the same way as addition but uses modular
multiplication. That is, find
(? × ?) ??? 47.
> abcqH*AUydkzAB
the result that should be printed is
'abcqH' * 'AUydkzAB' => 'aUbbbZab'
> yyyyyyyyyyyy*abcdefghijkl
the result that should be printed is
'yyyyyyyyyyyy' * 'abcdefghijkl' => 'aybzcAdBeCfD'
Inversion on a finite field: /
For this operation, given two numbers X / Y, find a number Z such
that ? = (? × ?) ??? 47. However,
if Y is zero, then this operation is undefined, so set the output
to zero.
> abcqHU/Aabdk
the result that should be printed is
'abcqHU' / 'Aabdk' => 'aacviu'
> bbbbb/ABCDU
the result that should be printed is
'bbbbb' / 'ABCDU' => 'MhQnU'
In: Computer Science
MATLAB
Create a function that prints a string of perfect cubes between (m,n). Include any reasonable error statements such as decimals and negative numbers.
In: Computer Science
Sorting and Searching
Given an unsorted array numbers of integers with duplicate values. Sort the array and remove the duplicates in-place such that each element appears only once in the input array and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Find the time complexity of your removeDuplicates() method in Big-O notation and write that in a comment line on the top of your code.
Hints: Sort the array before finding the number of unique elements. You can use any sorting algorithm that you have learned in the class. Do not use the built-in sorting algorithm of java.
Clarification:
Confused why the returned value of removeDuplicates() method is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller (main() method) as well.
Example 1:
Input: {1, 2, 1}
Output: {1, 2}
Your removeDuplicates() method should return length = 2, with the two unique elements of numbers being 1 and 2. It doesn't matter what you leave beyond the returned length.
Example 2:
Input: {2, 1, 0, 1, 2, 0, 3, 3, 2, 1}
Output: {0, 1, 2, 3}
Your removeDuplicates() method should return length = 4, with the four unique elements of numbers are 0, 1, 2, and 3. It doesn't matter what values are set beyond the returned length.
USE THIS CODE:
import java.util.Scanner;
class Main {
// add your sorting algorithm code here
public static int removeDuplicates(int[] numbers){
// your code goes here for removing duplicates
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the size of the array > ");
int n = scan.nextInt();
int[] numbers = new int[n];
System.out.print("Enter the array elements with duplicates in it
> ");
for(int i = 0; i < n; i++){
numbers[i] = scan.nextInt();
}
int len = removeDuplicates(numbers);
for(int i = 0; i < len; i++)
System.out.print(numbers[i] + " ");
System.out.println();
scan.close();
}
}
In: Computer Science
Case-IT Auditing
ABC has a sound change management process/policy for program code changes that includes the ability for users to request changes which are entered by users through a web based internally managed portal (CMP)ICS). User requests are then electronically routed to the appropriate IT and business personnel for review and approval to proceed to work the request. Once IT completes the coding revisions and performs unit and system testing, then users will test the system changes. Upon satisfactory testing the users will formally approve the movement of code to production using the web-based change portal. IT will then work with the business areas to move the code from the test environment to production at the agreed to time. All testing support is retained. ABC IT department maintains a downtime window on Sundays that allow time for code migrations. Additionally, this same downtime window allows for appropriate full backups to occur for all systems. During the week incremental backups occurs.
Question: What are the Controls and what are the GAPS
In: Computer Science