Java Programing
Write a program called reverseProg.
This program will do the following
Sample output example:
Enter a string: Wilmington University
String Entered is: Wilmington University
Wilmington University spelled backward is: ytsirevinU notgnimliW
The 7th character in the string is: T
The 8th character in the string is: O
The 9th character in the string is: N
Length of the string is: 21
In: Computer Science
What python codes should I use to solve this question below?
Use input() function once to retrieve an input and assign that input value to a variable. Check if the input contains the string “an”. If so, use input() function one more time to retrieve an input and assign the new input value to a different variable. Now, replace “an” characters in the first variable with the first two characters of the second variable if only the second variable has at least two characters
In: Computer Science
Java Program
The program must prompt for an integer divisor in the range 10-20 and will print all numbers 1-1000 that are divisible by that divisor. You MUST use a while loop for this. Use printf to display the numbers in right-aligned columns, 10 to a line. For example, “%5d” would be the format String to allow a field width of 5 to display the number. If the number entered by the user is out of range just print an error message.
In: Computer Science
What is the DUAL table?
Explain the USER function.
Explain the ROWNUM pseudocolumn.
What is a sequence?
Answer the following in reference to sequences
a. Show the SQL code to create a sequence per the following:
Sequence Name: testsequence
Starts with: 100
Increments by: 2
b. Show the SQL command to display the next available sequence value (1st value).
c. Show the SQL command to display the next available sequence value (2nd value).
d. Show the SQL command to display the current sequence value.
e. Show the SQL code to delete the sequence
In: Computer Science
In: Computer Science
The todo section in java please
LinkedStack class (provided as a skeleton) is to implement TextbookStackInterface using chain of nodes to manage the data (see the textbook implementation).
The instance variable topNode is defined as chain head reference. The empty stack should have this variable set to null.
Skeleton of LinkedStack class is provided. Please note that in addition to all the methods defined in the TextbookStackInterface there are two methods: displayStack and remove that you also need to implement:
The class includes main with test cases to test your methods. The output of your program must match the sample run below:
SAMPLE RUN
*** Create a stack ***
--> Pushing A B C D E on the stack
Done adding 5 elements.
The content of the stack:
E
D
C
B
A
--> Testing peek, pop, isEmpty:
E is at the top of the stack.
E is removed from the stack.
D is at the top of the stack.
D is removed from the stack.
C is at the top of the stack.
C is removed from the stack.
B is at the top of the stack.
B is removed from the stack.
A is at the top of the stack.
A is removed from the stack.
--> The stack should be empty:
isEmpty() returns true
CORRECT - exception has been thrown: cannot complete peek() - stack is empty
CORRECT - exception has been thrown: cannot complete pop() - stack is empty
The stack is empty
--> Testing clear:
--> Pushing A B C D E F G on the stack
Done adding 7 elements.
The content of the stack:
G
F
E
D
C
B
A
--> Calling clear()
The stack is empty
--> Testing remove:
--> Calling remove(4) on empty stack
0 elements have been removed.
The stack is empty
--> Pushing A B C D E F G H I J on the stack
Done adding 10 elements.
The content of the stack:
J
I
H
G
F
E
D
C
B
A
--> Calling remove(4)
removing J
removing I
removing H
removing G
4 elements have been removed.
The content of the stack:
F
E
D
C
B
A
--> Calling remove(10)
removing F
removing E
removing D
removing C
removing B
removing A
6 elements have been removed.
The stack is empty
*** Done ***
Process finished with exit code 0
public final class LinkedStack<T> implements TextbookStackInterface<T> { private Node<T> topNode; // references the first node in the chain public LinkedStack() { // TODO PROJECT #3 } // end default constructor public void push(T newEntry) { // TODO PROJECT #3 } // end push public T peek() throws InsufficientNumberOfElementsOnStackException { // TODO PROJECT #3 return null; // THIS IS A STUB } // end peek public T peek2() throws InsufficientNumberOfElementsOnStackException { // TODO PROJECT #3 return null; // THIS IS A STUB } // end peek2 public T pop() throws InsufficientNumberOfElementsOnStackException { // TODO PROJECT #3 return null; // THIS IS A STUB } // end pop public boolean isEmpty() { // TODO PROJECT #3 return false; // THIS IS A STUB } // end isEmpty public void clear() { // TODO PROJECT #3 } // end clear public int remove(int numberOfElements) { // TODO PROJECT #3 return 0; // THIS IS A STUB } // end remove public void displayStack() { // TODO PROJECT #3 } // end displayStack
public interface TextbookStackInterface<T> { /** Adds a new entry to the top of this stack. @param newEntry An object to be added to the stack. */ public void push(T newEntry); /** Removes and returns this stack's top entry. @return The object at the top of the stack. throws appropriate exception if the stack is empty before the operation. */ public T pop(); /** Retrieves this stack's top entry. @return The object at the top of the stack. throws appropriate exception if the stack is empty. */ public T peek(); /** Detects whether this stack is empty. @return True if the stack is empty. */ public boolean isEmpty(); /** Removes all entries from this stack. */ public void clear(); } // end StackInterface
In: Computer Science
To understand the value of counting loops:
Sample Result is shown below:
Enter the number of rows of matrix A: 2
Enter the number of columns of matrix A: 3
Enter the number of columns of matrix B: 3
Enter the number of columns of matrix B: 4
Enter matrix A;
1 2 3
4 5 6
Enter matrix B:
7 8 9 10
11 12 13 14
15 16 17 18
Matrix A:
1 2 3
4 5 6
Matrix B:
7 8 9 10
11 12 13 14
15 16 17 18
Product of matrix A and Matrix B ( A x B) :
74 80 86 92
173 188 203 218
In: Computer Science
In java please create a class with a method to be able to add ints into a linked List and to be able to print out all the values at the end.
public class Node {
int data;
Node next;
In: Computer Science
In: Computer Science
Write a program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.)
The program should accomplish all of the following:
a. Store the information in a 3×5 array.
b. Compute the average of each set of five values.
c. Compute the average of all the values.
d. Determine the largest value of the 15 values.
e. Report the results.
Each major task should be handled by a separate function using the traditional C approach to handling arrays.
Accomplish task “b” by using a function that computes and returns the average of a one-dimensional array; use a loop to call this function three times.
The other tasks should take the entire array as an argument, and the functions performing tasks “c” and “d” should return the answer to the calling program.
Must be done in C for DEV C++
In: Computer Science
This exercise will test your ability to use the basic instance methods of String. The exercise is to create a program that compares two Strings ignoring the case and returns the offset between the first two distinct characters in the two Strings from left to right.
All the input strings have five characters.
For this exercise, compareToIgnoreCase() and compareTo() methods are not allowed.
Example 1, "London" and "Lately" will return the offset between 'o' and 'a', which is 14
Example 2, "London" and "lately" will return the offset between 'o' and 'a', which is 14
Example 3, "LONDON" and "lately" will return the offset between 'o' and 'a', which is 14
Example 4, "LONDON" and "Loathe" will return the offset between 'n' and 'a', which is 13
Example 4, "LONDON" and "london" will return 0
The class name should be: Lab14_CustomizedStringComparison
In: Computer Science
What kind of problems attributes make in entropy-based decision trees. How can we solve them?
In: Computer Science
by python
Question #1 Consider a 5-point quiz system. A score can be any number between 0 and 5. Using mathematical interval notation, the score is in the interval [0,5][0,5]. The interval notation (4,5](4,5] means that number 4 is not in the interval. Hence the numbers included in this interval are all real values ?x such that 4<?≤54
The score is graded according to the following scale:
Score | Grade |
---|---|
(4, 5] | A |
(3, 4] | B |
(2, 3] | C |
(1, 2] | D |
[0, 1] | F |
Write a program that reads a quiz score and then prints out the corresponding grade.
Note that your program should
The following are two sample runs of the program:
Sample Run 1:
Please enter score: -1
Invalid score. Try again.
Please enter score: 5.5
Invalid score. Try again.
Please enter score: 3.5
Your grade is B
In: Computer Science
For this project, you will create a program in C that will test the user’s proficiency at solving different types of math problems. The program will be menu driven. The user will select either addition, subtraction, multiplication or division problems. The program will then display a problem, prompt the user for an answer and then check the answer displaying an appropriate message to the user whether their answer was correct or incorrect. The user will be allowed 3 tries at each problem. The program will also keep statistics on how many problems were answered correctly.
This week you will add functions to allow the user to select problems of varying degrees of difficulty and also keep statistics on number of correct answers vs. total number of problems attempted.
So now let’s add the code for the remaining functions:
We’ll start by inserting code to ask the user if they want to see problems that are easy, medium or difficult. We’ll do this by prompting them to enter ‘e’ for easy, ‘m’ for medium or ‘d’ for difficult and we’ll do this right after they have selected the type of problems they want. We will also add a validation loop that will check to see if they entered a correct response (e,m, or d).
Easy – problems using numbers 0 thru 10
Medium – problems 11 thru 100
Difficult – problems 100 – 1000
Here’s some code to get you started on the “difficulty level.”
if( difficultyLevel == 'E')
{
num1=rand()%10+1;
num2=rand()%10+1;
}
else
if (difficultyLevel == 'M')
{num1=rand()%100+1;
num2=rand()%100+1;
}
else
{ num1=rand()%1000+1;
num2=rand()%1000+1;}
Use an “if” statement to check the difficulty and generate the random numbers.
Statistics:
Create two variables ttlProblems and correctAnswers. Every time the user answers a problem add 1 to ttlProblems and every correct answer add 1 to correctAnswers. We’ll display the total number of problems and correct answers as well as the percent correct after the user has selected the exit option on the main menu.
Then, alter the code to allow for floating point numbers. This requires formatting the output.
In: Computer Science
JAVA :
Many games are played with dice, known as a die in the singular. A die is a six-sided cube whose sides are labeled with one to six dots. The side that faces up indicates a die's face value.
Design and implement a Java class Die that represents one 6-sided die. You should be able to roll the die and discover its upper face. Thus, give the class the method int roll, which returns a random integer ranging from 1 to 6, and the method int getFaceValue, which returns the current face value of the die (last value rolled). Note a call to roll will return the same value as a subsequent call to getFaceValue.
Often, games depend on the roll of two dice. Using your class Die, design and implement a Java class TwoDice with an aggregation ("has-a") relationship to the Die class. An object of TwoDice represents two six-sided dice that are rolled together. Include at least the following TwoDice methods: int rollDice, int getFaceValue1, int getFaceValue2, int getValueOfDice (returns the sum of the two dice values), boolean isMatchingPair, boolean isSnakeEyes, andString toString.
Demonstrate your Die and TwoDice classes using the following test client:
public class Main
{
public static void main(String[] args)
{
Die dieOne = new Die();
Die dieTwo = new Die();
Die dieThree = new
Die();
System.out.println("Demonstrating the Die class:");
System.out.println("Rolling
dieOne: " + dieOne.roll());
System.out.println("Rolling
dieTwo: " + dieTwo.roll());
System.out.println("Rolling
dieThree: " + dieThree.roll());
TwoDice dice = new
TwoDice();
System.out.println("Demonstrating the TwoDice class: ");
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
dice.rollDice();
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
dice.rollDice();
System.out.println("Rolling
dice: [" + dice.getFaceValue1()
+ ", " + dice.getFaceValue2() + "]");
}
}
In: Computer Science