Q. In java, I would like to know, especially how the program detect there is an error which is user should put only numerical data but if user put letter data (five, sixty instead of 5,60), *I want the program display "Invalid data. Please try again" instead of long error message(from the IDE)* when user put letter data(five, sixty stuff...) and GO BACK TO THE BEGINNING SO USER CAN PUT THE DATA AGAIN!
Write a program that counts change. The program should ask for the number of quarters, the number of dimes, the number of nickels and the number of pennies. The program should then compute the value of all the coins and tell the user how much money there is, expressed in dollars. Display a title at the top of the screen when the program first runs. You must use constants for the value of each coin type. Multiply the number of each coin times the value for each coin (the defined constant). Refer to the PowerPoint or video on the use of the constants.
1) if quarters =100 dimes = 100 nickels = 100 pennies = 99
=>expected result = 40.99
2) if quarters = hundred dimes = hundred nickels = nine pennies = hundred
=> expected result ""Invalid data. Please try again" (GO BACK TO THE BEGINNING, SO USER CAN PUT THE DATA AGAIN!) <- this is the part i am struggling. Please Help!
In: Computer Science
1. Circle:
Implement a Java class with the name Circle. It should be in the package edu.gcccd.csis.
The class has two private instance variables: radius (of the type double) and color (of the type String).
The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated.
Construction:
A constructor that constructs a circle with the given color and sets the radius to a default value of 1.0.
A constructor that constructs a circle with the given, radius and color.
Once constructed, the value of the radius must be immutable (cannot be allowed to be modified)
Behaviors:
Accessor and Mutator aka Getter and Setter for the color attribute
Accessor for the radius.
getArea() and getCircumference() methods, hat return the area and circumference of this Circle in double.
Hint: use Math.PI (https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI (Links to an external site.))
2. Rectangle:
Implement a Java class with the name Rectangle. It should be in the package edu.gcccd.csis.
The class has two private instance variables: width and height (of the type double)
The class also has a private static variable: numOfRectangles (of the type long) which at all times will keep track of the number of Rectangle objects that were instantiated.
Construction:
A constructor that constructs a Rectangle with the given width and height.
A default constructor.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
getArea() and getCircumference() methods, that return the area and circumference of this Rectangle in double.
a boolean method isSquare(), that returns true is this Rectangle is a square.
Hint: read the first 10 pages of Chapter 5 in your text.
3. Container
Implement a Java class with the name Container. It should be in the package edu.gcccd.csis.
The class has two private instance variables: rectangle of type Rectangle and circle of type Circle.
Construction:
No explicit constructors.
Behaviors:
Accessor and Mutator aka Getter and Setter for both member variables.
an integer method size(), that returns 0, if all member variables are null, 1 either of the two member variables contains a value other than null, and 2, if both, the rectangle and circle contain values other than null.
In: Computer Science
Problem 1:
More than 2500 years ago, mathematicians got interested in numbers.
Armstrong Numbers: The number 153 has the odd property that 13+53 + 33 = 1 + 125 + 27 = 153. Namely, 153 is equal to the sum of the cubes of its own digits.
Perfect Numbers: A number is said to be perfect if it is the sum of its own divisors (excluding itself). For example, 6 is perfect since 1, 2, and 3 divide evenly into 6 and 1+ 2 + 3 = 6.
Input File
The input is taken from a file named number.in and which a sequence of numbers, one per line, terminated by a line containing the number 0.
Output File
All the numbers read from the input file, are printed one per line followed by a sentence indicating whether the number is or is not Armstrong number and whether it is or is not a perfect number. Sample Input 153 6 0 Sample Output 153 is an Armstrong number but it is not a perfect number. 6 is not an Armstrong number but it is a perfect number.
Note: the program must be write in java
In: Computer Science
Identify the major steps involved in the data file update process
In: Computer Science
Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. The input marks must be inserted one subject at a time. The program then calculate percentage and grade according to given conditions:
If percentage >= 90% : Grade A
If percentage >= 80% : Grade B
If percentage >= 70% : Grade C
If percentage >= 60% : Grade D
If percentage >= 40% : Grade E
If percentage < 40% : Grade F
Example1: Please input marks of five subjects.
Physics: 95
Chemistry: 95
Biology: 97
Mathematics: 98
Computer: 90
Percentage = 95.00
Grade A
Example2: Please input marks of five subjects.
Physics: 85
Chemistry: 80
Biology: 95
Mathematics: 98
Computer: 70
Percentage = 85.60
Grade B
In: Computer Science
You are to create a page that has four images that are links to other schools in the New England area. Each image is to be controlled in size by a CSS responsive design. The page is to appear balanced by an appropriate, complimentary, background color. White is not an option as a background color. Look up how to make image links on W3Schools.There is to be a small repeated background image that appears on the right side of the page but not at the edge of the page. There is to be a header banner in a header section (look up "header" tag on W3Schools).The link images are to run vertically down the screen but they may not cover any part of the background image or the header banner.All images are to be in good taste and should represent the site to which they connect. The image does not have to be an exact image of that school but it has to be related.You can't use a fish image to represent a University.
Add an ordered list to your page that will list the current standings of the top eight teams in the National Football League. The list must be styled with CSS and can not use any of the default colors, fonts, or sizes. The first letter of each team's name must be a different color.No content may be against any of the screen edges.Make sure that your submission includes all folders required in your site structure.
In: Computer Science
Arrange the following binary tree types in increasing order of height with the worst-case height of each type.
Binary Tree
Full Binary Tree
Complete Binary Tree
Binary Search Tree
Balanced Binary Tree
In: Computer Science
Create a dynamic array-based Queue ADT class in C++ that contains enqueue(Inserts newElement at the back ) and dequeue(Removes the frontmost element ). If the size of the array is equal to the capacity a new array of twice the capacity must be made.
The interface is shown:
class Queue {
private:
int* elements;
unsigned elementCount; // number of elements in the queue
unsigned capacity; // number of cells in the array
unsigned frontindex; // index the topmost element
unsigned backindex; // index where the next element will be placed
public:
// Description: Constructor
Queue();
// Description: Inserts newElement at the back (O(1))
void enqueue(int newElement);
// Description: Removes the frontmost element (O(1))
// Precondition: Queue not empty
void dequeue();
// Description: Returns a copy of the frontmost element (O(1))
// Precondition: Queue not empty
int peek() const;
// Description: Returns true if and only if queue empty (O(1))
bool isEmpty() const;
};
Thanks!
In: Computer Science
Powerball. In this assignment you are to code a program that selects 20 random non-repeating positive numbers (the Powerball Lottery numbers), inputs three numbers from the user and checks the input with the twenty lottery numbers. The lottery numbers range from 1 to 100. The user wins if at least one input number matches the lottery numbers.
As you program your project, demonstrate to the lab instructor displaying an array passed to a function. Create a project titled Lab6_Powerball. Declare an array wins of 20 integer elements.
Define the following functions:
Hint: Array elements are assigned 0, which is outside of lottery numbers' range, to distinguish elements that have not been given lottery numbers yet.
Passing an array as a parameter and its initialization is done similar to the code in this program.
#include <iostream>
using std::cout; using std::endl; using std::cin;
// initializes the array by user input
void fillUp(int [], int);
int main( ) {
const int arraySize=5;
int a[arraySize];
fillUp(a, arraySize);
cout << "Echoing array:\n";
for (int i = 0; i < arraySize; ++i)
cout << a[i] << endl;
}
// fills upt the array "a" of "size"
void fillUp(int b[], int size) {
cout << "Enter " << size << " numbers: ";
for (int i = 0; i < size; ++i)
cin >> b[i];
}Hint: Looking for the match is similar to looking for the minimum number in this program.
#include <iostream>
using std::cout; using std::endl; using std::cin;
int main(){
const int arraySize=5;
int numbers[arraySize]; // array of numbers
// entering the numbers
cout << "Enter the numbers: ";
for(int i=0; i < arraySize; ++i)
cin >> numbers[i];
// finding the minimum
int minimum=numbers[0]; // assume minimum to be the first element
for (int i=1; i < arraySize; ++i) // start evaluating from second
if (minimum > numbers[i])
minimum=numbers[i];
cout << "The smallest number is: " << minimum << endl;
}
Hint: Use srand(), rand() and time() functions that we studied earlier to generate appropriate random numbers from 1 to 100 and fill the array. Before the selected number is entered into the array wins, call function check() to make sure that the new number is not already in the array. If it is already there, select another number.
The pseudocode for your draw() function may be as follows:
declare a variable "number of selected lottery numbers so far",
initialize this variable to zero
while (the_number_of_selected_elements is less than the array size)
select a new random number
call check() to see if this new random number is already in the array
if the new random number is not in the array
increment the number of selected elements
add the newly selected element to the array
#include <iostream>
using std::cout; using std::endl; using std::cin;
// initializes the array by user input
void fillUp(int [], int);
int main( ) {
const int arraySize=5;
int a[arraySize];
fillUp(a, arraySize);
cout << "Echoing array:\n";
for (int i = 0; i < arraySize; ++i)
cout << a[i] << endl;
}
// fills upt the array "a" of "size"
void fillUp(int b[], int size) {
cout << "Enter " << size << " numbers: ";
for (int i = 0; i < size; ++i)
cin >> b[i];
}
The pseudocode your function main() should be as follows:
main(){
declare array and other variables
assign(...) // fill array with 0
draw(...) // select 20 non-repeating random numbers
iterate three times
entry(...) // get user input
use check () to compare user input against lottery numbers
if won state and quit
printOut(...) // outputs selected lottery numbers
}
Note: A program that processes each element of the array separately (i.e. accesses all 20 elements of the array for assignment or comparison outside a loop) is inefficient and will result in a poor grade.
Note 2: For your project, you should either pass the array size (20) to the functions as a parameter or use a global constant to store it. Hard-coding the literal constant 20 in function definitions that receive the array as a parameter is poor style. It should be avoided.
In: Computer Science
Why is security so important to wireless networks? Give two
examples of defense measures that should be taken to enhance
wireless security.
In: Computer Science
Write a class called CombineTwoArraysAlternating that combines two
lists by alternatingly taking elements, e.g.
[a,b,c], [1,2,3] -> [a,1,b,2,c,3].
You must read the elements of the array from user input by reading
them in a single line, separated by spaces, as shown in the examples
below.
Despite the name of the class you don't need to implement this class
using arrays. If you find any other way of doing it, as long as it
passes the test it is ok.
HINTS:
You don't need to use any of my hints. As long as you pass the test
you can write the code any way you want.
I used:
String [] aa = line.split("\\s+");
to split the String contained in the variable called 'line' into
strings separated by at least one white space character. For
example if line is "hello world how are you?" the previous statement
populates array aa in such a way that
aa[0] is: "hello"
aa[1] is: "world"
aa[2] is: "how"
aa[3] is: "are"
aa[4] is: "you?"
I used the method Arrays.toString from java.util.Arrays to print
arrays. For example the following lines of code:
String line = "hello world how are you?";
String [] aa = line.split("\\s+");
//Arrays.toString(aa) takes array aa and returns a nicely formatted String
System.out.println(Arrays.toString(aa));
produce the following output:
[hello, world, how, are, you?]
In: Computer Science
For Cloud Database Encryption Technology Based on Combinatorial Encryption
You are required to research and report on this topic according to the Detail of Question below.
A. understand in order to present three main parts:
1. Summary:
o Provide a 200-300 word summary of the paper under review, from the background to the results being presented, and further work proposed. Please do NOT copy the abstract into this space!
2. Main points:
o The main issues as you see them.
o This is different than the summary.
3. Strengths and Weaknesses:
o Provide some critical analysis of the paper under review, positive and/or negative.
In: Computer Science
What do you understand by pre- and post-conditions
of a function?
Write the pre- and post-conditions to axiomatically specify the
following
functions:
(a) A function takes two floating point numbers representing the
sides of
a rectangle as input and returns the area of the
corresponding
rectangle as output.
(b) A function accepts three integers in the range of -100 and +100
and
determines the largest of the three integers.
(c) A function takes an array of integers as input and finds the
minimum
value.
(d) A function named square-array creates a 10 element array
where
each all elements of the array, the value of any array element
is
square of its index.
(e) A function sort takes an integer array as its argument and
sorts the
input array in ascending order.
In: Computer Science
Suppose you turn on a system and everything is dead- no lights, nothing on the monitor screen, and no spinning fan or hard drive. You verify the power to the system works, all power connections and power cords are securely connected, and all pertinent switches are turned on. you are now sure the power supply has gone bad. Explain in 2 to 3 paragraph how you will go about to buy and install a new power supply and making sure the problem is resolved.
In: Computer Science
Create and display an XML file in Android studio that has
-One edittext box the does NOT use material design
-One edittext box that DOES use material design
Provide a “hint” for each, and make sure the string that comprises the hint is referenced from the strings.xml file.
Observe the differences in how the hints are displayed.
Here is sample code for a material design editText:
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_price1Text"
android:layout_width="80dp"
android:layout_height="40dp"
>
<EditText
android:id="@+id/price1Text"
android:importantForAutofill="no"
tools:targetApi="o"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="6"
android:inputType="numberDecimal"
android:hint="@string/hint_text"
/>
</android.support.design.widget.TextInputLayout>
It requires this to be added to the build.gradle Module:app
implementation 'com.android.support:design:28.0.0'
Take a screenshot, Make sure the screenshot clearly shows the two different ways that the hints are displayed.
In: Computer Science