An array of prime numbers 2-499 is stored in a file "primeNumbers.txt". This program can allow to request a number from the user and find the closest prime number to the input number (either higher or lower) and print the lower one if the number is in the middle of two. Your program should run interactively until the user quits. Try to minimize the program execution time by using the appropriate searching method for finding the prime number(s). You need to record and report the number of comparisons executed for finding the prime numbers. Sample Output Enter a number between 2 and 499.1 This number is outside the accepted range.
Q: In Ocaml Write a function mode : ’a list -> ’a = that given a (nonempty) list it returns an element…
A: In this question we have to wirte a OCaml function that computes the mode of a given non-empty list,…
Q: A) Write a Little Man program that accepts three values as input and produces the largest of the…
A: The Little Man Computer (LMC) is a simplified instructional model of a computer. It's designed to…
Q: Can I use a MUX 74151 for the following output? A’B’[(C+D)⊕(AB)’]. If so, please explain. Thanks!
A: Introduction:The 74151 is a flexible eight-enter multiplexer/demultiplexer incorporated circuit (IC)…
Q: Suppose we assign n persons to n jobs. Let,C base ij, be the cost of assigning the i^th person to…
A: The assignment problem is a classic problem in optimization where the objective is to assign a set…
Q: For each of the following business situations, identify and justify the most suitable Management…
A: The objective of the question is to identify the most suitable subtype of Management Information…
Q: Hello, I'm having difficulty with question 2.7 as I'm unsure how to approach it. Could you please…
A: In this question we have to design a Pushdown Automata for the language, A )The set of strings over…
Q: Need help with python code. Write a LikedStack . Test it by: Add numbers from 7 to 22 in the stack.…
A: The objective of the question is to implement a LinkedStack in Python and perform various operations…
Q: how computers science corelate with infomation communication technology
A: The objective of this question is to understand the correlation between computer science and…
Q: d) Implement your algorithm and show a test case of it
A: In this question we have to implement a algorithm where cost matrix representing the cost of…
Q: Sequential Circuit - Design an unsigned 3-bit counter using J-K flip-flops that increments by three…
A: For the unsigned 3-bit counter using JK flip-flops:J1 = Q2' * Q1' * E' + Q2 * EK1 = EJ2 = Q1' * Q2'…
Q: Can you tell me the error in this code and how to fix that error? #include void main() { struct…
A: The following are the issues in the given C programming language of code:Addition of default value…
Q: Project Description: Metaprogramming The automatic generation of programs has been a research topic…
A: In this question we have to write a code to understand the meta programming. We will also understand…
Q: Hi, I'm struggling with question 2.7 and I'm not sure what to do next. Would you be able to generate…
A: In this question we have to design a Push down automata for the language {a^n b^n | n ≥ 0}Where, the…
Q: Match the following expressions to their corresponding types in C. '*'=42 &a +1 Drag answer here…
A: The following are the correct matchings for the given C statements with their data-types:42…
Q: Apply the Paint Blue algorithm discussed in class to the following Finite Automata. a a a b b a a +…
A: The Paint Blue AlgorithmThe Paint Blue algorithm is a technique used to determine whether a given…
Q: Can you write a Java Socket Programs for Client and Server. What ever your write on Client Program,…
A: This type of program enables the communication between two entities over a network using the sockets…
Q: what is the formula for load factor of a hash table? explain each term used in the formula
A: The required answer is given below:Explanation: Understanding the Load Factor of a Hash Table: The…
Q: How to find the shortest paths in the following graph from node N to each of the other nodes using…
A: Dijkstra's algorithm is a widely used approach for determining the shortest path between nodes in a…
Q: Show that a tree with n vertices has n-1 edges
A: In this question we have to prove a tree with n vertices has n-1 edges. A tree is an undirected…
Q: Q6 Describe the features of a distributed database management system (DDBMS).
A: A complex network solution that maintains data across numerous locations or nodes is called a…
Q: Instructions Task: Exception handling This program will be reused in the next lab. Save it at a safe…
A: In this question we have to write a JAVA Code for the converion of binary to decimal and also…
Q: Q14) How do you model the following situation with a UML2 class diagram: A fitness center consists…
A: option A is correct these type of model is reflexive association and aggregation.Explanation: Answer…
Q: Write a program in C to assist in circuit calculations (No previous knowledge in circuits is…
A: The objective of the question is to create a C program that assists in circuit calculations. The…
Q: The following details are given for an online store selling books. You are asked to develop the…
A: The objective of the question is to design a database for an online bookstore. The database should…
Q: Draw the logic diagram corresponding to the following Boolean expressions without simplifying them:…
A: Our guidelines is answer the first three subparts from the first so we will see in the more details…
Q: You work for an insurance company. An analyst comes into your office in a panic. They have been…
A: The objective of the question is to explain Bayes' Theorem and its application in risk assessment in…
Q: Write the Boolean expression for the following circuit. A B C
A: The output expression is determined as, Y=Aˉ.B.CExplanation: Some important properties in…
Q: 1. Prove that Σ(Φ) = 2(2)" - 1) i=0 for any nonnegative integer n.
A: We will prove the statement by using mathematical induction. The complete steps are given in the…
Q: I need a line by line explination as to how the below Python program works. I am having a hard time…
A: The objective of the question is to understand how the Python program works, especially the part…
Q: css code with these properties: 1. background color: blue 2. background image: photo3.jpg 3. border…
A: I have provided a complete HTML code with CSS styling that incorporates all the properties you…
Q: Eliminate the A-productions from the following CFG: S → AbC A → aA | ВС B → AabC|C CaA | Bc | A
A: The original grammar had productions for a variable A, but A couldn't be used to generate any…
Q: Test it by: Add numbers from 13 to 23 in the queue. Print the length of the queue Check if the…
A: The question asks to implement a LinkedQueue class in Python and test its functionality by…
Q: In C Write the function definition for a function named “bet” that has no parameters and returns an…
A: In the C programming language, a function is a self-contained block of code that performs a…
Q: If you wanted to list the files in a directory on a UNIX system, what command would you use to see…
A: UNIX is a robust, multi-user, multitasking operating system developed in the 1970s. Known for its…
Q: Convert the regular expression 0(0+1)*11 to an \epsi - NFA in such a way that you are guaranteed…
A: In this question we have to deisgn a NFA state diagram for the given regular…
Q: Computer Architecture Convert the following IEEE single-precision floating-point numbers to their…
A: As per the IEEE 754 standard, a standard format for representing floating-point numbers in computing…
Q: This function uses a curious mix of iteration and recursion: function F(n) if n < 1 t<- O return 1…
A: It is essential to comprehend algorithms' computational complexity in order to assess their…
Q: Database The solution is in clear handwriting
A: 1. Find the name of Publisher along with the book which they published. (Using Relational…
Q: Please help with solution for these parts!! a) give a Description of the approach b)…
A: We can follow these steps:Read the text file to extract the following information:Number of…
Q: Please give advantages and disadvantages of alternative strategies Specify how your recommendations…
A: JetBlue Airways (JBLU) is a major American low-cost airline known for its affordable fares and…
Q: Isn't the actual optimal S->B->G. If yes, then how are the assumed heuristics valid?
A: You are correct in stating that the actual optimal path from start node S to goal node G in the…
Q: (Amdahl’s law question) Suppose you have a machine which executes a programconsisting of 50%…
A: The objective of the question is to determine if it is possible to meet management's goal of making…
Q: In the context of an operating system, an interrupt is a mechanism that allows the CPU to…
A: The objective of the question is to understand the concept of interrupts in the context of an…
Q: Construct a diagram to depict the structure of an HTTP response. Elucidate every component of the…
A: The question asks for a diagram illustrating the structure of an HTTP response, including the status…
Q: Encode the function f(w, x, y, z) = Σm(0, 1, 3, 4, 7, 6, 9, 11, 10, 13, 14). You must label your…
A: Minterms are binary expressions representing all possible combinations of inputs in a Boolean…
Q: Please answer the question in the attachment. It is a past AP Computer Science frq question that has…
A: The objective of the question is to implement the method 'evaluateLight' in the 'LightBoard' class.…
Q: Q1 Consider the following regular grammar with start symbol S. {SaS, SaB, SaA, A→bS, A→ bB, AA, BaS,…
A: Regular Grammar:Regular Grammar is a formalism used in formal language theory and automata theory.…
Q: The following is a dataset of bridges in Pittsburgh. The original dataset was prepared by Yoram…
A: The objective of the question is to clean and prepare a dataset of bridges in Pittsburgh for…
Q: Show how depth-first search works on the graph below. Assume that the for loop of lines 5-7 of the…
A: Depth-First Search (DFS) is a fundamental algorithm used for traversing or searching tree or graph…
Q: Convert the following FA into a PDA. a S± b X+ b a Y b a a Ꮓ b
A: To convert the given finite automaton (FA) into a pushdown automaton (PDA), we need to define the…
Alert dont submit
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.Write a program called FiveLetterWords that: prints your name followed by three asterisks; reads the words in a text file into a String array, where each array entry contains a word; prints the number of words in the file; counts and prints the number of five-letter words; prints all of the five-letter words starting with a vowel (that is, 'a', 'e', 'i', 'o', or 'u'); finds and prints the alphabetically first five-letter word and the alphabetically last five-letter word. tale.txt file content : it was the best of times it was the worst of timesit was the age of wisdom it was the age of foolishnessit was the epoch of belief it was the epoch of incredulityit was the season of light it was the season of darknessit was the spring of hope it was the winter of despairWrite a program called Words that: prints your name followed by three asterisks; reads the words in a text file into a String array, where each array entry contains a word; prints the number of words in the file; counts and prints the number of five-letter words; prints all of the five-letter words starting with a vowel (that is, 'a', 'e', 'i', 'o', or 'u'); finds and prints the alphabetically first five-letter word and the alphabetically last five-letter word. it was the best of times it was the worst of timesit was the age of wisdom it was the age of foolishnessit was the epoch of belief it was the epoch of incredulityit was the season of light it was the season of darknessit was the spring of hope it was the winter of despairwe had everything before us we had nothing before uswe were all going direct to heaven we were all going directthe other wayin short the period was so far like the presentperiod that some of its noisiest authorities insisted on itsbeing received for good or…
- Write a void method selectionSortDescendTrace() that takes an integer array, and sorts the array into descending order. The method should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete main() to read in a list of up to 10 positive integers (ending in -1) and then call the selectionSortDescendTrace() method. If the input is: 20 10 30 40 -1 then the output is: 40 10 30 20 40 30 10 20 40 30 20 10write a program that will open a file called “story.txt”and count the number of occurrences of each letter from the alphabet in this file.At the end your program will output the following report:Number of occurrences for the alphabets:a was used – times.b was used – times.c was used – times…. …and so, onAssume the file contains only lower-case letters and for simplicity just a singleparagraph. Your program should keep a counter associated with each letter of thealphabet (26 counters) [Hint: Use array]Your program should also print a histogram of characters count by addinga new function print Histogram (int counters []). This function receives thecounters from the previous task and instead of printing the number of times eachcharacter was used, prints a histogram of the counters. An example histogram forthree letters is shown below) [Hint: Use the extended asci character 254]:In JAVA, write a program in a single file that: Main: Creates 10 random doubles, all between 1 and 11, Calls a method that writes 10 random doubles to a text file, one number per line. Calls a method that reads the text file and displays all the doubles and their sum accurate to two decimal places. SAMPLE OUTPUT 10.62691196041722.7377903389094555.4279257388651281.37420580654725091.18587002624988364.1803912764852284.9109699989306755.7108582343439587.7908570073730523.1806714736219543 The total is 47.13
- The program in Java language. Do not use Java's ArrayList. Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in each fraction and count the number of occurrences for the current fraction. When all the input is consumed (or as the input is consumed), your program will print out its list of unique fraction and their corresponding count — see the output below (and you may assume no blank lines or misleading characters; see the text file link on the website for one of the actual inputs I’ll use when testing your submission). The fractions should always be represented as two integers - DO NOT USE DECIMALS. Only use arrays to hold your data. Do not use Java's ArrayList. We will discuss in class how to grow your array. Sample Text Input 6/3 7/3 6/3 12/6 Sample Console Output 6/3 has a count of 3 7/3 has a count of 1In the Utils class provided to you in this exercise, please fill in the details for a method called swapArray(). You can either upload a file or use the Edit tab to submit your work. The VPL tester will pass an arbitrary array of type integer to your method, along with the value of the locations in the array of two values that need to be swapped (exchanged). For instance, in the illustration below, the method swapArray is told to swap the values in positions 0 and 2 of an array made up of {10, 20, 30, 40, 50}. The three input parameters to the method are the array, as well as the two array indices (i and j) that control which elements to swap. Your task is to write the contents of the method that can execute this swap.Write a Java program named searchForLastOccurence that :Asks the user to enter an integer value that represents the size of an array of integersPrompt the user to fill an array of integersASks the user to enter a key valueThe program should search for the last occurrence of the key value in the array and displays its positionin the arrav. OR disolavs -I it the value is not found in the arrav.
- Write a static method called runningSum that accepts an array parameter, populated with a sequence of real numbers that are read from a file. The program outputs the running sum of the numbers followed by the maximum running sum. For example, if the array contains the following data: Use loops instead of in-built methods. (Java programming language) 3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25 your method should produce the following output: running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25 max sum = 14.5Write a static method called runningSum that accepts an array parameter, populated with a sequence of real numbers that are read from a file. The program outputs the running sum of the numbers followed by the maximum running sum. For example, if the array contains the following data: 3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25 your method should produce the following output: running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25 max sum = 14.5Write a static method called runningSum that accepts an array parameter, populated with a sequence of real numbers that are read from a file. The program outputs the running sum of the numbers followed by the maximum running sum. For example, if the array contains the following data: 3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25 your method should produce the following output:running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25max sum = 14.5 CODE is javascript only