Problem: HugeIntegerClass
Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each. Provide methods Input, toString, Add, and Subtract. For comparing HugeInteger objects, provide the following methods: IsEqualTo, IsNotEqualTo, IsGreaterThan, IsLessThan, IsGreaterThanOrEqualTo and IsLessThanOrEqualTo. Each of these is a method that returns true if the relationship holds between the two HugeInteger objects and returns false if the relationship does not hold. Provide method IsZero. In the Input method, use the string method toCharArray to convert the input string into an array of characters, then iterate through these characters to create your HugeInteger. If you feel ambitious, provide methods Multiply, Divide, and Remainder
// Driver Class
Import.java.*;
public class <LastName>_HugeIntegerTest
{
public static void Main(string[] args)
{
HugeInteger integer1 = new
HugeInteger();
HugeInteger integer2 = new
HugeInteger();
System.out.println("Enter
first HugeInteger: ");
integer1.Input(Console.ReadLine());
System.out.println ("Enter
second HugeInteger: ");
integer2.Input(Console.ReadLine());
System.out.println
("HugeInteger 1”+ integer1);
System.out.println ("HugeInteger 2”
+integer2);
HugeInteger result;
// add two
HugeIntegers
result =
integer1.Add(integer2);
System.out.println ("Add result” +
result);
// subtract two
HugeIntegers
result =
integer1.Subtract(integer2);
System.out.println ("Subtract
result” + result);
// compare two
HugeIntegers
System.out.println ( "HugeInteger 1
is zero: “ + integer1.IsZero());
System.out.println ( "HugeInteger 2
is zero: “ + integer2.IsZero());
System.out.println (
"HugeInteger 1 is
equal to HugeInteger 2: “ + integer1.IsEqualTo(integer2));
System.out.println (
"HugeInteger 1 is
not equal to HugeInteger 2:” +
integer1.IsNotEqualTo(integer2));
System.out.println (
"HugeInteger 1 is
greater than HugeInteger 2: “ +
integer1.IsGreaterThan(integer2));
System.out.println (
"HugeInteger 1 is
less than HugeInteger 2:” + integer1.IsLessThan(integer2));
System.out.println (
"HugeInteger 1 is
greater than or equal to HugeInteger 2: “ +
integer1.IsGreaterThanOrEqualTo(integer2));
System.out.println ( "HugeInteger 1
is less than or equal to HugeInteger 2: “ +
integer1.IsLessThanOrEqualTo(integer2));
}
}
Sample Run 1:
Enter first HugeInteger:
1234567890123456789012345678901234567890
Enter second HugeInteger:
0987654321098765432109876543210987654321
HugeInteger1 +1234567890123456789012345678901234567890
HugeInteger2 +987654321098765432109876543210987654321
Add result+2222222211222222221122222222112222222211
Subtract result+246913569024691356902469135690246913569
HugeInteger 1 is zero: false
HugeInteger 2 is zero: false
HugeInteger 1 is equal to HugeInteger 2: false
HugeInteger 1 is not equal to HugeInteger 2:true
HugeInteger 1 is greater than HugeInteger 2: true
HugeInteger 1 is less than HugeInteger 2:false
HugeInteger 1 is greater than or equal to HugeInteger 2: true
HugeInteger 1 is less than or equal to HugeInteger 2: false
Sample Run 2:
Enter first HugeInteger:
65479876253763637782636782636
Enter second HugeInteger:
989
HugeInteger1 +65479876253763637782636782636
HugeInteger2 +989
Add result+65479876253763637782636783625
Subtract result+65479876253763637782636781647
HugeInteger 1 is zero: false
HugeInteger 2 is zero: false
HugeInteger 1 is equal to HugeInteger 2: false
HugeInteger 1 is not equal to HugeInteger 2:true
HugeInteger 1 is greater than HugeInteger 2: true
HugeInteger 1 is less than HugeInteger 2:false
HugeInteger 1 is greater than or equal to HugeInteger 2: true
HugeInteger 1 is less than or equal to HugeInteger 2: false
public class HugeInteger
{
private final int DIGITS = 40;
private int[] integer;// array containing the integer
private boolean positive; // whether the integer is positive
// parameterless constructor
public HugeInteger()
{
//
}
// Convert a string to HugeInteger
public void Input(String inputstring)
{
//
}
// add two HugeIntegers
public HugeInteger Add(HugeInteger addValue)
{
//
}
// add two positive HugeIntegers
private HugeInteger AddPositives(HugeInteger addValue)
{
//
}
// subtract two HugeIntegers
public HugeInteger Subtract(HugeInteger subtractValue)
{
//
}
// subtract two positive HugeIntegers
private HugeInteger SubtractPositives(HugeInteger subtractValue)
{
//
}
// find first non-zero position of HugeInteger
private int FindFirstNonZeroPosition()
{
//
}
// get string representation of HugeInteger
public String toString()
{
//
}
// test if two HugeIntegers are equal
public boolean IsEqualTo(HugeInteger compareValue)
{
//
}
// test if two HugeIntegers are not equal
public boolean IsNotEqualTo(HugeInteger compareValue)
{
//
}
// test if one HugeInteger is greater than another
public boolean IsGreaterThan(HugeInteger compareValue)
{
//
}
// test if one HugeInteger is less than another
public boolean IsLessThan(HugeInteger compareValue)
{
//
}
// test if one HugeInteger is greater than or equal to another
public boolean IsGreaterThanOrEqualTo(HugeInteger compareValue)
{
//
}
// test if one HugeInteger is less than or equal to another
public boolean IsLessThanOrEqualTo(HugeInteger compareValue)
{
//
}
// test if one HugeInteger is zero
public boolean IsZero()
{
//
}
//Optional
public HugeInteger multiply(HugeInteger multiplyValue)
{
//
}
}
In: Computer Science
Please Use your keyboard (Don't use handwriting) Thank you..
I need new and unique answers, please. (Use your own words, don't copy and paste)
Q1:
Your team is asked to program a self-driving car that reaches its destination with minimum travel time.
Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.
Q2:
Write a complete Java program that prints out the following information:
Note:Your program output should look as shown below.
My Name: Ameera Asiri
My student ID: 123456789
My Course Name: Computer Programming
My Course Code: CS140
My Course CRN: 12345
AIYSHA ASIRI
Note : Include the screenshot of the program output as a part of your answer.
_____
Q3:
Write a tester program to test the given class definition.
Create the class named with your id with the main method.
Your answer should be supported with the screenshot of the output, else zero marks will be awarded.
public class Mobile
{
int id;
String brand;
public Mobile()
{
id = 0;
brand="";
}
public Mobile(int n, String name)
{
id = n;
brand=name;
}
public void setBrand(String w)
{
brand = w;
}
public void setId(int w)
{
id = w;
}
public int getId()
{
return id;
}
public String getBrand()
{
return brand;
}
}
___
Q4:
Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID.
Your answer should be supported with a screenshot of the program with output.
In: Computer Science
Consider f,g:ℤ→ℤ given by:
Which of the following statements are true? Select all that apply
| (a) |
f is an injection |
| (b) |
g is an injection |
| (c) |
f∘g is an injection |
| (d) |
g∘f is an injection |
| (e) |
f is a surjection |
| (f) |
g is a surjection |
| (g) |
f∘g is a surjection |
| (h) |
g∘f is a surjection |
In: Computer Science
In: Computer Science
Using SET operations, display a list of customers that are interested in a car (prospect table) of the same make and model which they already own.
In: Computer Science
Which command do you use to find the process that’s holding a file open?
| 1. |
w |
|
| 2. |
ps |
|
| 3. |
top |
|
| 4. |
fuser |
In: Computer Science
As a second example, consider the communication paradigm referred to as queued RPC, as introduced in Rover [Joseph et al. 1997]. Rover is a toolkit to support distributed systems programming in mobile environments where participants in communication may become disconnected for periods of time. The system offers the RPC paradigm and hence calls are directed towards a given server (clearly space-coupled). The calls, though, are routed through an intermediary, a queue at the sending side, and are maintained in the queue until the receiver is available. To what extent is this time- uncoupled? Hint: consider the almost philosophical question of whether a recipient that is temporarily unavailable exists at that point in time.
In: Computer Science
why are direct input and outputs highly discouraged in setters and getters
In: Computer Science
9. #include
<fstream>
#include <iostream>
using namespace std;
int main()
{
float bmi;
ifstream inFile;
inFile.open("bmi.txt");
while (!inFile.eof())
{
inFile >>
bmi;
if( bmi <
18.5)
{
cout << bmi << " is underweight " ;
}
else if( bmi >= 18.5
&& bmi <= 24.9)
{
cout << bmi << " is in normal range " ;
}
else if( bmi >= 25.0
&& bmi <= 29.9)
{
cout << bmi << " is overweight " ;
}
else if( bmi >=
30)
{
cout << bmi << " is obese " ;
}
cout <<
endl;
}
return 0;
}
bmi.txt looks like below:
25.0
17.3
23.1
37.0
What will be the output when the above code runs with the above bmi.txt file.
In: Computer Science
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics library to make an interactive sketching program that will allow the user to do line drawings. The user should be able to choose from a palette of colors displayed on the screen. When the user clicks the mouse in the color palette area, the drawing tool will switch to using the color selected, much like dipping a paint brush into a new color of paint.
Here are two starter codes. I'm trying to combine them basically but end up with a mess. It's supposed to be mimicking Microsoft Paint. Pick a color and then draw a line with it. There are 3 boxes on the left side, red, green, and blue. When the user clicks the box the line color matches the color of the box. Then the user can click in the space and free draw a line of that color, similar to Microsoft paint.
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
# global variables
width = 400 # window dimensions
height = 300
menuwidth = 100 # menu dimensions
ncolors = 3 # number of colors
boxheight = height//ncolors # height of each color box
colormenu = [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]
menuindex = -1
###
# Returns true if point (x, y) is in the color menu
###
def incolormenu(x, y):
return x >= 0 and x <= menuwidth and y >= 0 and y <= height
###
# Returns index of point (x, y) in the color menu
###
def colormenuindex(x, y):
if not incolormenu(x, y):
return -1;
else:
return y//boxheight
###
# Watch mouse button presses and handle them
###
def handleButton(button, state, x, y):
global menuindex
y = height - y # reverse y, so zero at bottom, and max at top
if button != GLUT_LEFT_BUTTON: # ignore all but left button
return
# if button pressed and released in same menu box, then update
# the color of the large square
if state == GLUT_DOWN:
if incolormenu(x, y):
menuindex = colormenuindex(x, y)
else:
if incolormenu(x, y) and colormenuindex(x, y) == menuindex:
glColor3f(colormenu[menuindex][0], colormenu[menuindex][1], colormenu[menuindex][2])
glRecti(menuwidth, 0, width, height)
glFlush()
###
# Draw the colored box and the color menu
###
def drawMenu():
# clear window
glClear(GL_COLOR_BUFFER_BIT)
# draw the color menu
for i in range(ncolors):
glColor3f(colormenu[i][0], colormenu[i][1], colormenu[i][2])
glRecti(1, boxheight * i + 1, menuwidth - 1, boxheight * (i + 1) - 1)
glFlush()
###
# Main program
###
def main():
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(width, height)
window = glutCreateWindow("Color Menu")
# callback routine
glutDisplayFunc(drawMenu)
glutMouseFunc(handleButton)
# lower left of window is (0, 0), upper right is (width, height)
gluOrtho2D(0, width, 0, height)
# specify window clear (background) color to be black
glClearColor(0, 0, 0, 0)
glutMainLoop()
if __name__ == "__main__":
main()
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
# global variables
width = 600 # window dimensions
height = 600
wleft = 0
wright = width
wbottom = 0
wtop = height
tracking = False
###
# Returns true if point (x, y) is in the window
###
def inwindow(x, y):
return x > wleft and x < wright and y > wbottom and y < wtop
###
# Draw a line to new mouse position
###
def m_Motion(x, y):
y = wtop - y
if tracking and inwindow(x, y):
glBegin(GL_LINES)
glVertex2i(width//2, height//2)
glVertex2i(x, y)
glEnd()
glFlush()
###
# Watch mouse button presses and handle them
###
def handleButton(button, state, x, y):
global tracking
y = wtop - y
if button != GLUT_LEFT_BUTTON:
return
if state == GLUT_DOWN:
if inwindow(x, y):
tracking = True
else:
tracking = False
###
# Clear the window
###
def drawMouse():
glClear(GL_COLOR_BUFFER_BIT) # clear the window
glColor3f(0, 0, 0) # set mouse line color
glFlush()
###
# Main program
###
def main():
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA)
glutInitWindowSize(width, height)
window = glutCreateWindow("Mouse Exam")
# callback routine
glutDisplayFunc(drawMouse)
glutMouseFunc(handleButton)
glutMotionFunc(m_Motion)
# lower left of window is (0, 0), upper right is (width, height)
gluOrtho2D(0, width, 0, height)
# specify window clear (background) color to be dark grey
glClearColor(0.7, 0.7, 0.7, 1)
glutMainLoop()
if __name__ == "__main__":
main()
In: Computer Science
//Write in C++
//use this evote code and add File I/O operations (as specified in the comments) to it.
#include<iostream>
using namespace std;
int main()
{int choice;
int bezos = 0 , gates = 0 , bugs = 0 ;
int vc = 0 ;
do {
cout<<"\n\n\nEVOTE\n-----"
<<"\n1.Jeff Bezos
<<"\n2.Bill Gates
<<"\n3.Bugs Bunny"
// 4. Print current tally [hidden admin option]
// 5. Print audit trail [hidden admin option]
// 6. mess with the vote [hidden hacker option] E.C.
// 7. END THE ELECTION
<<"\n\n Your selection? ";
cin >> choice ;
if(choice==1) {bezos++ ; vc++ ; cout<<"\nThanks for voting!"; }
if(choice==2) {gates++ ;vc++ ; cout<<"\nThanks for voting!"; }
if(choice==3) { bugs++ ; vc++ ; cout<<"\nThanks for voting!"; }
if((choice<1)||(choice>7))cout<<"\nPlease enter 1-3";
// write what happened to FILES
// Tally.txt (overwrite) bezos x gates x bugs x
// auditTrail.txt ios::app (everything typed) 1 2 3 3 56 -12 4
} while(choice != 7 ) ;
cout<<"\n\nRESULTS:\n--------"
<<"\nTotal Votes Cast This Election: "<< vc
<<"\nJeff Bezos: "<< bezos
<<"\nBill Gates: "<< gates
<<"\nBugs Bunny: "<<bugs;
cout<<"\n\n";
system("pause"); // leave this out if using newer DEV C++
return 0;
}
In: Computer Science
A) DDL
For Company DB Schema, Answer the below questions:
Emp (Empno, Ename, Job, Hiredate, Sal, Comm, Deptno)
Dept (Deptno, Dname, loc)
1. Retrieve the data of all employees.
2. Retrieve the data of all Salemanemployees.
3. Retrieve the name and Salary of all employees.
4. Retrieve the name and salary of Salemanemployees.
5. Retrieve the name and salary of all employees with Salary more than 2000.
6. Retrieve the Name and Salary of all employees who work in department no 20.
7. Retrieve the name and Job of all employees with Salary more than 2000 and hiredate after 01-01-1981.
8. Retrieve the Job and Salary of all employees with Name = FORD or MARTIN.
9. Retrieve the Name and Number of all Departments.
10. Retrieve the Employee Name and Department number for all employees.
11. Retrieve the Employee Name and Department name for all employees.
12. Retrieve the Employee Name and who works in Department name = RESEARCH.
13. Retrieve the Employee names who workin one of these Departments: RESEARCHand SALES.
14. Retrieve the Employee name who works in department located in NEW YORK.
please write in computer word not on paper
In: Computer Science
Urgent need: please solve this question below:
A description of how your chosen Information Systems Technology is currently being used in different areas of business, government or and/or society. If your technology is being used in many different areas, try and focus on four areas that either have a high impact or that interest your group. Be sure to include the impacts that the technology is having on each of these areas. Your impacts should include both quantitative (e.g., financial, etc.) as well as qualitative (e.g., quality of life, etc.) ones. In addition, describe 3-4 advantages and 3-4 disadvantages of the use of the technology in these areas. For the advantages, you should clearly describe how/why these are advantages, whether or not they are sustainable and why. For the disadvantages, you should clearly describe why they are disadvantages, how serious these disadvantages are and whether or not there are any ways to overcome these disadvantages.
In: Computer Science
Define an interface called Vehicle, which requires the following methods getName: returns a String getTopSpeed: returns an int getMaxPassengers: returns an int Note that the class Car implements this interface and is preloaded (in one of the following questions you will define this class)
For example:
Test
Vehicle v = new Car("BMW", 280, 5); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers());
Results :
BMW
280
5
Test 2 :
Vehicle v = new Car("Smart", 150, 2); System.out.println(v.getName()); System.out.println(v.getTopSpeed()); System.out.println(v.getMaxPassengers());
Results :
Smart
150
2
In: Computer Science
Question 3 a) What kind of leadership style would you like to apply as a project manager to lead your team? AN b) With a typical case study example, show how you would go about your project scope management. AP c) In your own view, how can scope creep affect project success?
In: Computer Science