USE JAVA
Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a pair containing the minimum and maximum value. Require that the array elements implement the Measurable interface of Chapter 10.
In: Computer Science
reate a class Song with the data members listed below:
Include the following member functions:
You only need to write the class definition and any code that is
required for that class (i.e., header and implementation).
NOTE: you must not use the implicit "private" for class data types
and methods. Include public or private explicitly.
In: Computer Science
In C++, create two vectors, one a vector of ints and one a vector of strings. The user will fill each one with data, and then your program will display the values.
Sample Output
The following is an example of output for this program:
Enter int: 3
Enter int: 12
Enter int: 4
Enter int: 0
Your list is:
3
12
4
Enter string: The
Enter string: quick
Enter string: brown
Enter string: fox
Enter string: jumps
Enter string: over
Enter string: the
Enter string: lazy
Enter string: dog
Enter string: quit
Your list is:
The
quick
brown
fox
jumps
over
the
lazy
dog
In: Computer Science
Can I get detailed explanation about the following topics
Keyword Queries
Boolean Queries
Phrase Queries
Proximity Queries
Natural Language Queries
Wildcard Queries
Rather than the solution for Chapter 27, proplem 18RQ in Fundamentals of database system (6th Edition) and also provide me with examples
Regards
In: Computer Science
using java. using eclipse. write a program that asks to enter 3 real numbers using GUI. print the sum if all 3 numbers are positive, print the product of the 2 positive numbers if one is negative, use one nested if statement. all output should be to dialog and the console. ...... So i have most of this program done, i just cant figure out how to get the product of the 2 positve numbers to print to the console and dialog. Here is what I have so far.... i know the if and else if statements are correct, i just dont know how to get the if and else if to print to console and dialog correctly for the product.
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Project3 {
public static float getFloat(){
String s = JOptionPane.showInputDialog("Enter a real
number");
return Float.parseFloat(s);
}
public static void main(String[] args) {
float x = getFloat();
float y = getFloat();
float z = getFloat();
// if all three are positive print the sum
if(x>0 && y>0 && z>0)
System.out.printf("Sum:%8.2f\n", (x+y+z));
//if two of the three are positive print the
product
else if((x>0 && y>0 &&
z<0)||(x>0 && y<0 && z>0)||(x<0
&& y>0 && z>0));
System.out.printf("Product:%8.2f",((x*y)||(x*z)||(y*z)));
JOptionPane.showMessageDialog(null,
"Sum:"+(x+y+z)+"\nProduct:"+((x*y)||(x*z)||(y*z)));
Scanner scan=new Scanner(System.in);
System.out.println("\nEnter 2 real numbers");
// if both are negative print the quotient
float a = scan.nextFloat();
float b = scan.nextFloat();
if(a<0 && b<0)
System.out.printf("Quotient:%8.2f", (a/b));
JOptionPane.showMessageDialog(null,
"Quotient:"+(a/b));
System.exit(0);
}
}
In: Computer Science
*I JUST WANT A GENERAL WALKTHROUGH OF HOW TO DO THIS. PSEUDOCODE IS FINE. THANK-YOU. THIS IS IN C THE PROGRAMMING LANGUAGE.*
The program will require the following structure:
struct _data {
char *name;
long number;
};
The program will require command line arguments:
int main(int argv, char **argc) {
Where argv is the number of arguments and argc is an array
holding the arguments (each is a string). Your program must catch
any case where no command line arguement was provided and print
a warning message (see below).
You MUST include/use the following functions, defined as follows:
int SCAN(FILE *(*stream)) - this function will open the file/stream
and return an integer indicating how many lines there are. Note that
I need to pass stream, which is a pointer, by reference. So I am
passing this as a pointer to a pointer.
struct _data *LOAD(FILE *stream, int size) - this function will
rewind file, create the dynamic array (of size), and read in the
data, populating the _data struct dynamic array. Note that stream
is passed by value this time. The function then returns the populated
array of struct.
void SEARCH(struct _data *BlackBox, char *name, int size) - this function
will get the dynamic array of struct passed to it, the name we are looking
for, and the size of the array. This function will then search the dynamic
array for the name. See below for examples.
void FREE(struct _data *BlackBox, int size) - this function will free up
all of the dynamic memory we allocated. Take note of the number of times
malloc/calloc were called, as you need to free that same number.
Finally, the data file will be called hw5.data and will be formatted as:
ron 7774013
jon 7774014
tom 7774015
won 7774016
HINTS:
------
Functions that will make things much easier:
getline()
feof()
strtok()
atoi()
SAMPLE RUNS:
------------
Case 1 - No command line argument provided.
[yourname@chef junk]$ ./CS230-5
*******************************************
* You must include a name to search for. *
*******************************************
Case 2 - Provided name is NOT in the list.
[yourname@chef junk]$ ./CS230-5 joe
*******************************************
The name was NOT found.
*******************************************
Case 3 - Provided name is in the list.
*******************************************
The name was found at the 2 entry.
*******************************************
In: Computer Science
Express the following bit patterns in hexadecimal.
01000101011001110100010101100111
10001001101010111000100110101011
11111110110111001111111011011100
00000010010100100000001001010010
In: Computer Science
Python Questions
Suppose we run the Python program my_program.py from command line like this:
Python my_program.py 14 CSC121
Which of the following statement in my_program.py will display CSC121?
| A. |
import sys print(sys.argv) |
|
| B. |
import sys print(sys.argv[0]) |
|
| C. |
import sys print(sys.argv[1]) |
|
| D. |
import sys print(sys.argv[2]) |
from datetime import datetime dob = datetime(2015, 1, 1)
Which of the following statements will change year to 2018?
| A. |
dob.year=2018 |
|
| B. |
dob.replace(year=2018) |
|
| C. |
dob = dob.replace(year=2018) |
|
| D. |
dob.set_year(2018) |
10 points
QUESTION 4
from datetime import datetime dob = datetime(2011,12,10) today = datetime.now() age = today - dob
What is the type of age?
| A. |
int |
|||||||||||||
| B. |
float |
|||||||||||||
| C. |
datetime |
|||||||||||||
| D. |
timedelta Which of the following functions returns integers between 0 and 20 that are divisible by both 2 and 3?
|
In: Computer Science
Q:Write a Java application which allows the user to enter student information
The user will enter full name, address, city, province, postal
code, phone number and email in text field controls. The student’s
major (Computer Science or Business) will be selected from two
radio buttons.
A combo box will display the list of courses for each program
whenever the user selects the desired program.
A course will be added to a list box whenever the user selects a
course from the corresponding combo box. Make sure that the user
cannot add a course several times.
Additional information about the student will be provided from a
group of check boxes (such as involvement in various activities,
etc).
All the information about the student will be displayed in a text
area component. Use simple SWING layout managers, such as
FlowLayout, BorderLayout, and GridLayout to create the SWING GUI of
this application. Provide the titles for the data that will be
displayed in the text area.
Note:I know how to do most of the things from question but i do not know how to implement layouts.
In: Computer Science
Write a program that will guess an integer that the user has picked. Imagine that the user will write down a positive integer x on a piece of paper and your program will repeatedly ask questions in order to guess what x is, and the user replies honestly. Your program will start by asking for an int n, and you must have 1 ≤ x ≤ n. After that, the program will successively guess what x is, and the user must tell the computer if x is equal to the guess (entering ’e’), larger than the guess (entering ’l’), or smaller than the guess (entering ’s’). Your program will guess by maintaining a lower bound (initially 1) and upper bound (initially n) and pick the largest integer equal to or smaller than1 the midpoint of the lower bound and upper bound. If the user responds with ’l’ indicating that x is larger, the guess becomes the new lower bound plus one. If the user responds with ’s’ indicating that x is smaller, the guess becomes the new upper bound minus one. If the user responds with ’e’ indicating that x is the guess, your program will report the number of guesses made and terminate execution:
Example 1)
Enter n: 50
Is your number 25? l
Is your number 38?
l Is your number 44? s
Is your number 41? e
Your number must be 41. I used 4 guesses.
Example 2)
Enter n: 9
Is your number 5? s
Is your number 2?
l Is your number 3? s
Error: that’s not possible.
Example 3)
Enter n: -2
Error: n must be positive.
Example 4)
Enter n: 9
Is your number 5? m
Error: invalid input.
Example 5)
Enter n: a
Error: invalid input.
In: Computer Science
In the Python:
Note 1: You may not use these python built-in functions:
sorted(), min(), max(), sum(), pow(), zip(), map(), append(), count() and counter().
(7 points) unique.py: A number in a list is unique if it appears only once. Given a list of
random numbers, print the unique numbers and their count. Print the duplicate numbers and
their count.
Sample runs:
Enter the size of the list : 7
[8, 2, 6, 5, 2, 4, 5]
There are 3 unique numbers: 8 6 4
There are 2 duplicate numbers: 2 5
Sample run:
Enter the size of the list : 7
[2, 2, 4, 3, 3, 3, 4]
There are 0 unique numbers:
There are 3 duplicate numbers: 2 3 4
In: Computer Science
Taking a test on "Inheritance" in C++ tomorrow. So far we have learned about classes, structs and arrays and strings. We will be provided with coding prompts and have to hand write codes that show examples of inheritance (most likely including some of the earlier concepts as well).
I would like some code examples such as this to study and look over with comments please.
In: Computer Science
Write a shoppingcartmanager.java that contains a main method for this code in java
Itemtopurchase.java
public class ItemToPurchase {
// instance variables
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
// default constructor
public ItemToPurchase() {
this.itemName = "none";
this.itemDescription =
"none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice,
int itemQuantity,String itemDescription) {
this.itemName = itemName;
this.itemDescription =
itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity =
itemQuantity;
}
// method to set name of the item
public void setName(String name) {
itemName = name;
}
// method to set price of the item
public void setPrice(int price) {
itemPrice = price;
}
// method to set quantity of the item
public void setQuantity(int quantity) {
itemQuantity = quantity;
}
public void setDescription(String description) {
itemDescription =
description;
}
// method to get name of the item
public String getName() {
return itemName;
}
// method to get price of the item
public int getPrice() {
return itemPrice;
}
// method to get quantity of the item
public int getQuantity() {
return itemQuantity;
}
public String getDescription() {
return itemDescription;
}
public void printItemPurchase() {
System.out.println(itemName + " " +
itemQuantity + " @ $" + itemPrice + " = $" + (itemPrice *
itemQuantity));
}
public void printItemDescription() {
System.out.println(itemName+":
"+itemDescription);
}
}
*******************
shoppingcart.java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ShoppingCart {
private String customerName;
private String currentDate;
private List<ItemToPurchase> cartItems=new
ArrayList<>();
ShoppingCart() {
customerName = "none";
currentDate = "January 1,
2016";
}
ShoppingCart(String customerName, String currentDate)
{
super();
this.customerName =
customerName;
this.currentDate =
currentDate;
}
public String getCustomerName() {
return customerName;
}
public String getDate() {
return currentDate;
}
public void addItem(ItemToPurchase item) {
cartItems.add(item);
}
public void removeItem(String itemName) {
boolean check = false;
for (ItemToPurchase item :
cartItems) {
if(item.getName().equalsIgnoreCase(itemName)) {
cartItems.remove(item);
check=true;
}
}
if(!check)
System.out.println("Item not found in cart. Nothing
removed.");
}
public void modifyItem(ItemToPurchase item) {
boolean check = false;
for (ItemToPurchase itemToPurchase
: cartItems) {
if(itemToPurchase.getName().equalsIgnoreCase(item.getName()))
{
cartItems.remove(itemToPurchase);
cartItems.add(item);
check=true;
}
}
if(!check)
System.out.println("Item not found in cart. Nothing
modified.");
}
public int getNumItemsInCart() {
int total=0;
for (ItemToPurchase item :
cartItems) {
total+=item.getQuantity();
}
return total;
}
public int getCostOfCart() {
int cost=0;
for (ItemToPurchase item :
cartItems) {
cost+=item.getPrice()*item.getQuantity();
}
return cost;
}
public void printTotal() {
System.out.println(customerName+"'s
Shopping Cart - "+currentDate);
System.out.println("Number of
Items: "+getNumItemsInCart());
System.out.println();
for (ItemToPurchase item :
cartItems) {
System.out.println(item.getName()+" "+item.getQuantity()+" @
$"+item.getPrice()+" =
$"+(item.getQuantity()*item.getPrice()));
}
System.out.println();
System.out.println("Total:
$"+getCostOfCart());
}
public void printDesciptions() {
System.out.println(customerName+"'s
Shopping Cart - "+currentDate);
System.out.println();
System.out.println("Item
Descriptions");
for (ItemToPurchase item :
cartItems)
System.out.println(item.getName()+":
"+item.getDescription());
}
public static void main(String[] args) {
Scanner sc=new
Scanner(System.in);
System.out.println("Enter
Customer's Name:");
String name=sc.nextLine();
System.out.println("Enter Today's
Date:");
String date=sc.nextLine();
ShoppingCart cart=new
ShoppingCart(name,date);
System.out.println();
System.out.println();
}
}
In: Computer Science
I'm trying to work with this code that I have. i want to kick the user back if they don't enter a number in the specified range but I haven't been able to get a while loop working right.
public class Blackjack_Jr
{
public static void main(String[] args)
{
int card1;
int card2;
int player1;
int dealer;
Random rand = new Random();
int card3 = rand.nextInt(11);
int card4 = rand.nextInt(11);
Scanner in = new
Scanner(System.in);
System.out.println("Blackjack
Jr!");
System.out.println();
System.out.print("Pick Your First
Card from 1-10: ");
card1 = in.nextInt();
System.out.print("Pick Your Second
Card from 1-10: ");
card2 = in.nextInt();
System.out.println();
player1 = card1 + card2;
dealer = card3 + card4;
System.out.print("You have entered
" +card1);
System.out.println(" and "
+card2);
System.out.println("Your total is:
" +player1);
System.out.println();
System.out.print("The dealer has
drawn " +card3);
System.out.println(" and "
+card4);
System.out.println("The dealer's
total is: " +dealer);
if(player1 >
dealer)
{
System.out.println("Congratulations! You
Won!");
}else
{
System.out.println("Sorry you have lost.
:-(");
}
}
}
In: Computer Science
Create a class Person with two instance variables of type String called firstName and
LastName, an instance variable of type int called age, an instance variables of type int
called height (measured in inches), and an instance variable of type double called weight.
Define an appropriate constructor that takes initial values for all instance variables and
calls the corresponding set methods. Define get and set methods for all instance variables.
All set (mutator) methods should validate that reasonable data is being passed to the
object.
Then create a test application that queries the user for information and uses that
information to create two objects of type Person. The application should display all
information about both objects.
language : java
In: Computer Science