Import Java Scanner Import Java Arraylist Import Java File Import Java Printwrit

import java.util.Scanner;import java.util.ArrayList;import java.io.File;import java.io.PrintWriter;public class task1{ public static void main(String[] args) {check_primes(“in1.txt”, “out1.txt”);System.out.printf(“Exiting…n”); }}

This is an incomplete program. The goal of the program is to:

  1. Read a file that contains integers.
  2. Determine if each of those integers is a prime or not.

Complete that program, by defining acheck_primesfunction, that satisfies the following specs:

  • Functioncheck_primestakes two arguments, calledin_file, out_file. Argumentin_filespecifies the name of the input file, that contains the integers to be processed. Argumentout_filespecifies the name of the output file, where the results will be saved.
  • Ifin_filecannot be opened for reading, the function should print on the screen “Error in opening file for reading” and return.
  • Ifout_filecannot be opened for writing, the function should print on the screen “Error in opening file for writing” and return.
  • Otherwise, if both in_file and out_file can be opened: for each integer X stored in in_file, the function writes to out_file a line stating either “X is prime” or “X is not prime”.

IMPORTANT: You are NOT allowed to modify in any way the main function.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Java Scanner Public Class Sums Public Static Void Main Stringargs Final I

Design and implement an application that reads an integer valueand prints the sum of all even integers between 2 and the inputvalue, inclusive. Print an error message if the input value is lessthan 2. Prompt the user accordingly.This is what I have, but my instructor said this isn’t right… I have no clue what to do now.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Java Util Scanner Public Class Distancetraveledtest Public Static Void Ma

I’m trying to use the method (getDistance) in my first class (DistanceTravled) to calculate the distance traveled in my second class (DistanceTraveledTest). I have the loop working correctly for the hours, but for some reason the getDistance method will not work correctly and I’ve tried different things to get it to work. I’ve attached my JAVA classes. 

The output should read like this:                            

Hours you have driven: 3

How fast were you going: 40

Hours                 Distance traveled

1                                        40

2                                        80

3                                        120

  • Attachment 1
  • Attachment 2

import java.util.Scanner;public class DistanceTraveledTest {public static void main(String args) {// TODO Auto-generated method stubint speed;int time;int i;Scanner scan = new…

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Javafx Scene Paint Color Import Javafx Scene Shape Circle Import Javafx S

Create a JavaFX Application named Bounce. In this Application you will use the Ball.java class to draw a red ball in the middle of a 500×500 window. The ball’s radius must be 20 pixels. Every 25 milliseconds move the ball by 10 pixels horizontally and 5 pixels vertically. Initially move it 10 pixels horizontally to the right, but as soon as your ball touches the right edge of the window, change its direction to go 10 pixels to the left. Then when it hits the left side, change it back to the right, and so on through an infinite loop. Also, initally move your ball 5 pixels vertically down, but after your ball touches the bottom edge of the window, change its direction to go 5 pixels up instead of down, until it hits the top, and then change its direction again, and so on through the same infinite loop that controls the horizontal direction. Furthermore, whenever your Ball hits any side, change its color to a random set of RGB values that are from 0.3 to 0.7 in the JavaFX Color class.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Numpy As Np Import Matplotlib Pyplot As Plt Load An Image I Plt Imread C

import numpy as np

import matplotlib.pyplot as plt

#load an image

I = plt.imread(‘C:UsersTinaDesktopimage.jpg’)

#display the shape of the array and data type

print(“I.shape=”,I.shape,”nI.dtype=”,I.dtype)

#convert to float data type and scale to [0..1] if necessary

if (I.dtype == np.uint8):

  I = I.astype(float) / 256

#I.dtype should now be float

#if your image is color (shape HxWx3), convert to grayscale by averaging together R,G,B values

R = np.array(img[:, :, 0])

G = np.array(img[:, :, 1])

B = np.array(img[:, :, 2])

R = (R *.299)

G = (G *.587)

B = (B *.114)

np.mean

#display the image in the notebook using a grayscale colormap

plt.imshow(I,cmap=plt.cm.gray)

#force matplotlib to go ahead and display the plot now

plt.show()  

#select out a 100×100 pixel subregion of the image

w,h = I.size

A = I.crop((w-50, h-50, w+50, h+50))

#display the selected subregion

plt.imshow(A,cmap=plt.cm.gray)

plt.show()

I am not sure if I am doing this right.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Random Class Person Object Friend Def Init Self Ssn Fname Lname Dob 0

I am working in Python and the question is for each person in the person list choose a number of friends (minimum is zero and maximum is size/200).  Assume this number is x.  Now you need to generate x locations of the friends and add them as friends to the list of friends of the current person.  The attached file shows that I have generated a random number using the random library.  However, how do I randomly select lines from the file and assign them to the friends list in the class.  I have attached both my code and the file I am using.

Once I complete this one, I will need to write a function that will sort the list by the number of friends in a descending order.  I think I have a function that will do that, but I am unable to test it, because I don’t think I am doing the first part correctly.  Then finally, for each person, I will need to find all people who have that person as a friend.  I think if I can figure out the first part, I can do the rest, but I am stuck on properly assigning friends.

  • Attachment 1
  • Attachment 2
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import String From Graphics Import Tells The User What The Program Does Def Prin

import stringfrom graphics import *# tells the user what the program doesdef printGreeting():print “This program finds hailstone sequences of numbers that you input.”print “The output numbers are found based on if it is odd or even.”print “If the number is odd, it is multiplied by 3 and then 1 is added to”print “it. If the number is even its divided in half.”# gives the user menu optionsdef printMenu():print “ntI : View sequences for an Individual valuen”print “tR : View sequences for a Range of Valuesn”print “tL : find the Longest Chainn”print “tH : view a Histogram of chain lengths for a rangen”print “tQ : Quitnnn”# returns number if it is odddef isOdd(n):return n % 2 == 1# creates a sequence of numbers and prints them outdef hailstone(num):sequence = [num]print “n %d –>>” % num,while num != 1:# odd number is multiplied by 3 and then adds 1# number is added to sequenceif isOdd(num):sequence.append(num)num = (num * 3) + 1# even number is divided by 2# number is added to sequenceelse:sequence.append(num)num = num / 2# prints numbersif num != 1:print num, “–>>”,else:# determines length of sequence and prints lengthlength = len(sequence)print “; length = “, lengthreturn length# finds the longest sequence in a range of numbers does not print them out# for the L option on menudef hailstone2(num):length = 1while num != 1:if isOdd(num):num = (num * 3) + 1length = length + 1else:num = num / 2length = length +1return length# error checks for bad numbersdef getValidInt(question, min, max):# use a bad value to enter the loopvalue = max + 1# compose the promptprompt = question + ” (” + str(min) + “-” + str(max) + “): “# continue to get values until the user enters a valid onewhile value == “” or value < min or value > max:value = raw_input(prompt)if len(value) != 0:value = int(value)# return a valid valuereturn valuedef longChain():quest1 = “Enter the starting interger “quest2 = “Enter the ending interger “startNum = getValidInt(quest1, 1, 10000)stopNum = getValidInt(quest2, startNum + 1, 10000)largestChain = startNumfor i in range(startNum, stopNum+1):if largestChain <= hailstone2(i):largestChain = ilength = hailstone2(i)print largestChain, ” had the longest chain “, lengthdef histogram():# initialize variableslongestLength = 1list = []start = input(“Please enter the beginning interger for the range: “)for n in range(start, start + 10):length = hailstone2(n)list.append(length)if longestLength <= hailstone2(n):longestLength = nlength = hailstone2(n)print longestLengthprint listdef main():choice = ”quest1 = “Enter the starting interger “quest2 = “Enter the ending interger “quest3 = “Enter a number”printGreeting()# runs program until they quitwhile choice != “Q” and choice != “q”:printMenu()choice = raw_input(“Enter your Choice: “)# runs program for numbers in rangeif choice == “r” or choice == “R” :start = getValidInt(quest1, 1, 10000)stop = getValidInt(quest2, start, 10000)for i in range(start, stop +1):hailstone(i)elif choice == “i” or choice == “I”:indVal = input(“Enter a number (1-10000): “)hailstone(indVal)elif choice == “l” or choice == “L”:longChain()elif choice == “h” or choice ==”H”:histogram()else:print choice, “is not a valid choice”printMenu()choice = input(“Please enter your choice : “).upper() BUT I WANT TO use some methods from the graphics library to draw a histogram of chain lengths for a range of values using the drawHistogram() function. This histogram will be drawn in a window thats is 500*500 and entitle it as “Histogram of chainlength”.For the y axis,The length of the longest chain plus some room for the labels at the bottom where n is shown.For the x axis, We want to show bars for 10 values and histograms look better if there is some space between the bars AND we’ll need some space on the left for the lengths to be printed. Let’s try 20.i want to have a range of 10 values and just let the user pick the starting value.want to allow the user to draw histograms for more than one range of numbers during the running of the program, we’ll want to close the window after having enough time to view it. You should close the window after 10 seconds. You’ll need to use sleep() to do this.All handling of the graphics window should be done within the drawHistogram() function.histogram should look like thishttp://www.cs.umbc.edu/courses/201/fall11/images/histo2.jpgplease i will need much help, i forever appreciate it.thanks in advance

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Import Sys Initial Beginning Balance Account Balance Float 500 25 Defines Balanc

import sys

#Initial beginning balance

account_balance = float(500.25)

#defines balance

def account_balance():

 #print the beggining balance amount

  print(“Your current balance:n$%.2f”%account_balance)

#defines deposit

def deposit_amount():

#req user to input amt of depsit

 deposit_amount = float(input(“How much would you like to deposit?”))

   # calulated new bal with amt deposited

account_balance = account_balance + deposit_amount**** keeps erroring and i can’t figure out the issue?  account_balance = account_balance + deposit_amount

TypeError: unsupported operand type(s) for +: ‘function’ and ‘function’

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Importance And Value Addition Of A Customer Loyalty Program For A Public Transpo

1.Importance and value addition of a customer loyalty program for a public transport organization such as the IRCTC.2. Illustration of two relevant customer loyalty programs that can be benchmarked for setting a loyalty program for IRCTC3. Key features of the recommended customer loyalty program for IRCTC.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW

Importance Of Photosynthesis Discuss Your Understanding Of How Photosynthesis Ha

Importance of Photosynthesis

Discuss your understanding of how photosynthesis has made the earth’s atmosphere unique in the solar system. What effects would decreasing levels of photosynthesis have on human society over time, and what could we do to stabilize photosynthesis over the long-term?

Your initial post should be at least 250 words and must substantively integrate the assigned readings from the module with proper APA (Links to an external site.)Links to an external site. style formatting// You may use additional sources and materials as long as they are relevant to the discussion and cited properly.

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
ORDER NOW