Write a program that uses a structure to store the following inventory information in a Binary file and access it using Random Access Method: Item description Quantity on hand Wholesale cost Retail cost Date added to inventory The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file Change any record in the file For exact menu option text please see the test cases below
In: Computer Science
Given a program as shown below:
#include <stdio.h>
void function1(void);
void function2 (int, double x);
void main (void)
{
int m;
double y;
m=15;
y=308.24;
printf ("The value of m in main is m=%d\n\n",m);
function1();
function2(m,y);
printf ("The value of m is main still m = %d\n",m);
}
void function1(void)
{
printf("function1 is a void function that does not receive\n\\r values from main.\n\n");
}
void function2(int n, double x)
{
int k,m;
double z;
k=2*n+2;
m=5*n+37;
z=4.0*x-58.4;
printf ("function2 is a void function that does receive\n\\r values from main.The values received from main are:\n\\r\t n=%d \n\r\t x=%lf\n\n", n,x);
printf ("function2 creates three new variable, k, m and z\n\\rThese variable have the values:\n\\r\t 1=%d \n\r\t m=%d \n\r\t z=%lf \n\n",k,m,z);
}
In: Computer Science
Please type out, not handwrite. THANKS!!
Compare and contrast Wireless networks and Home networks impact on the future of computing in a few paragraphs.
In: Computer Science
Prepare A Demo
Objective: What are the commands you would need to use to
backup your media files like music / pictures / movie folders and
backup media files, like .mp3 / .jpg / .mp4 or .mov files, into
their respective folders from a common media folder?
Process:
A) List, line by line, the sequence of commands needed to backup your media files.
B) Provide a brief description of what each section is doing between each section.
C) Example: Copying media files, with a blank line in between, what command is being used.
Use blank lines to between sections for readability in your
documentation. It is OK to list groups of commands or comments
without extra blank lines.
(No Screenshots please)
In: Computer Science
Example code of inserting nodes, deleting nodes, and deleting specific nodes in a Linked List in C++?
How do I create nodes? explain each line of code pleasee
In: Computer Science
this is java code
package calculator;
import java.util.Scanner;
import java.lang.Math;
public class Calculator {
public static void main(String[] args) {
double numx, numy;
Scanner scanner = new Scanner(System.in);
System.out.println(" Enter an operation :");
System.out.println("1: Addition");
System.out.println("2: Subtraction");
System.out.println("3: Multiplication");
System.out.println("4: Division");
System.out.println("5: Modulus");
System.out.println("6: Power");
System.out.println("7: Square");
System.out.println("8: Factorial");
System.out.println("9: Log");
System.out.println("10: Sin");
System.out.println("11: Absolute value");
System.out.println("12: Average Of Array Elements");
String operator = scanner.next();
System.out.println();
double output;
switch(operator)
{
case "1":
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output = sum( numx, numy);
break;
case "2":
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output = Subtraction( numx, numy);
break;
case "3":
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output = Multiplication( numx,numy);
break;
case "4":
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output = Division( numx, numy );
break;
case "5":
System.out.print("Enter first number:");
/* We are using data type double so that user
* can enter integer as well as floating point
* value
*/
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output =Modulus( numx,numy);
break;
case "6":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
System.out.print("Enter second number:");
numy = scanner.nextDouble();
output = power( numx, numy);
break;
case "7":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
output= Square_root( numx);
break;
case "8":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
output=factorial( numx);
break;
case "9":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
output=log1( numx); // log function
break;
case "10":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
output=sin1( numx); //sin finction
break;
case "11":
System.out.print("Enter first number:");
numx = scanner.nextDouble();
output=absolute( numx); //absolute function
break;
case "12":
output= average( );
break;
/* If user enters any other operator apart from
* then display an error message to user
*
*/
default:
System.out.printf("You have entered wrong operator");
return;
}
System.out.println(output);
}
public static double sum(double numx, double numy)
{
double sum=0;
return sum=numx+numy;
}
public static double Subtraction(double numx, double numy)
{
double sub=0;
return sub=numx-numy;
}
public static double Multiplication(double numx, double numy)
{
double Mul=0;
return Mul=numx*numy;
}
public static double Division(double numx, double numy)
{
double Division=0;
return Division=numx/numy;
}
public static double Modulus(double numx, double numy)
{
double Mod=0;
return Mod=numx%numy;
}
public static double power(double numx, double numy)
{
double output = Math.pow(numx, numy);
return output;
}
public static double Square_root(double numx)
{
double output = Math.sqrt(numx);
return output;
}
public static double factorial(double numx)
{
double factorial=1;
for(int i = 1; i <= numx; ++i) //loop for calculation of factorial
{
// factorial = factorial * i;
factorial *= i;
}
return factorial;
}
public static double log1(double numx)
{
double output=1;
return output=Math.log(numx);
}
public static double absolute(double numx)
{
double output=1;
return output=Math.abs(numx);
}
public static double sin1(double numx)
{
double output=1;
return output=Math.sin(numx);
}
public static double average( )
{
int n =1;
Scanner scanner = new Scanner(System.in);
double total = 0;
System.out.println("Enter size of array");
n=scanner.nextInt();
int i=0;
double[] arr = new double[n];
while(i<arr.length) // while loop for getting elements in array
{
System.out.print("Enter Element No."+(i+1)+": ");
arr[i] = scanner.nextDouble();
i++;
}
for(int j=0; j<arr.length; j++){ // loop to calculate sum of array
total = total + arr[j];
}
double average = total / arr.length;
return average;
}
}
for this code draw High level flowchart.
In: Computer Science
How do I stop the comma from printing at the end of Neptune?
#include <iostream>
using namespace std;
int main() {
string planets[] = {"Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"};
cout << "Contents in the array: ";
for(int i = 0; i < 8 ; i++) {
cout << *(planets + i) << ", ";
}
cout << endl;
return 0;
}
In: Computer Science
a) The ASCII code for the letter A is 1000001, and the ASCII code for the letter a is 1100001. Given that the ASCII code for the letter G is 1000111, without looking at Table 2.7, what is the ASCII code for the letter g?
b) The EBCDIC code for the letter A is 1100 0001, and the EBCDIC code for the letter a is 1000 0001. Given that the EBCDIC code for the letter G is 1100 0111, without looking at Table 2.7, what is the ASCII code for the letter g?
c) The ASCII code for the letter A is 1000001, and the ASCII code for the letter a is 1100001. Given that the ASCII code for the letter Q is 1010001, without looking at Table 2.7, what is the ASCII code for the letter q?
In: Computer Science
What is a NOSQL database? For what types of applications would be a NOSQL database preferred over a relational database. Provide the name of a NOSQL database used in the real world.
In: Computer Science
1. What are the names of the parts of a UNIX command? list them, and give a brief description of each.
2. Can multiple UNIX commands be typed on the same single command line? Explain how
3. How can you find out which utilities are available on your system for editing files? Which utilities are available for editing on your system?
4. What does the following command do? What is $PATH and echo $PATH?
5. What is the result of giving the which utility the name of a command that resides in a directory that is nor in your search path?
In: Computer Science
Assume that a disk has an average seek time of 9 msec and a rotation speed of 7000 RPM. Assume also that there are 40 sectors in a track. What is the average time expected to retrieve a single sector?
In: Computer Science
I need a sample of code of the below senario in Java with Spring Boot framework
Create a login and register page and user be able to register and then log in.
Data need to be stored from the user are:
Id, First Name, Last Name, DOB, Email, and Phone Number.
if user inputs the wrong credential system displays error.
please use JSPs. and JSTL dependencies
In: Computer Science
Python program problem:
A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set of numbers. Define these functions, median and mode, in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0 if the list is empty. Include a main function that tests the three statistical functions using the following list defined in main: userList = [3, 1, 7, 1, 4, 10] An example of the program output is shown below: List: [3, 1, 7, 1, 4, 10] Mode: 1 Median: 3.5 Mean: 4.33
In: Computer Science
package imageblocks;
import java.awt.Color;
import utils.Picture;
public class ImageBlocks {
static Color BLACK = new Color(0,0,0);
static Color WHITE = new Color(255,255,255);
private int height;
private int width;
boolean [][] visited;
Picture pic;
public ImageBlocks(Picture pic) {
this.pic = pic;
height = pic.height();
width = pic.width();
}
private boolean isBlack(int x,int y){
return pic.get(x,y).equals(BLACK);
}
private boolean isWhite(int x,int y){
return pic.get(x,y).equals(WHITE);
}
/**
* METHOD TO BE COMPLETED
* count the number of image blocks in the given image
* Counts the number of connected blocks in the binary digital
image
* @return number of black blocks
*/
public int countConnectedBlocks(){
//TODO
}
}
== Picture Class for Help ==
public final class Picture implements ActionListener {
private BufferedImage image; // the rasterized image
private JFrame frame; // on-screen view
private String filename; // name of file
private boolean isOriginUpperLeft = true; // location of origin
private final int width, height; // width and height
/**
* Initializes a blank <tt>w</tt>-by-<tt>h</tt> picture, where each pixel is black.
*/
public Picture(int w, int h) {
if (w < 0) throw new IllegalArgumentException("width must be nonnegative");
if (h < 0) throw new IllegalArgumentException("height must be nonnegative");
width = w;
height = h;
image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
// set to TYPE_INT_ARGB to support transparency
filename = w + "-by-" + h;
}
/**
* Initializes a new picture that is a deep copy of <tt>pic</tt>.
*/
public Picture(Picture pic) {
width = pic.width();
height = pic.height();
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
filename = pic.filename;
for (int x = 0; x < width(); x++)
for (int y = 0; y < height(); y++)
image.setRGB(x, y, pic.get(x, y).getRGB());
}
/**
* Initializes a picture by reading in a .png, .gif, or .jpg from
* the given filename or URL name.
*/
public Picture(String filename) {
this.filename = filename;
try {
// try to read from file in working directory
File file = new File(filename);
if (file.isFile()) {
image = ImageIO.read(file);
}
// now try to read from file in same directory as this .class file
else {
URL url = getClass().getResource(filename);
if (url == null) { url = new URL(filename); }
image = ImageIO.read(url);
}
width = image.getWidth(null);
height = image.getHeight(null);
}
catch (IOException e) {
// e.printStackTrace();
throw new RuntimeException("Could not open file: " + filename);
}
}
/**
* Initializes a picture by reading in a .png, .gif, or .jpg from a File.
*/
public Picture(File file) {
try { image = ImageIO.read(file); }
catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("Could not open file: " + file);
}
if (image == null) {
throw new RuntimeException("Invalid image file: " + file);
}
width = image.getWidth(null);
height = image.getHeight(null);
filename = file.getName();
}
/**
* Returns a JLabel containing this picture, for embedding in a JPanel,
* JFrame or other GUI widget.
*/
public JLabel getJLabel() {
if (image == null) { return null; } // no image available
ImageIcon icon = new ImageIcon(image);
return new JLabel(icon);
}
/**
* Sets the origin to be the upper left pixel.
*/
public void setOriginUpperLeft() {
isOriginUpperLeft = true;
}
/**
* Sets the origin to be the lower left pixel.
*/
public void setOriginLowerLeft() {
isOriginUpperLeft = false;
}
/**
* Displays the picture in a window on the screen.
*/
public void show() {
// create the GUI for viewing the image if needed
if (frame == null) {
frame = new JFrame();
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
menuBar.add(menu);
JMenuItem menuItem1 = new JMenuItem(" Save... ");
menuItem1.addActionListener(this);
menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
menu.add(menuItem1);
frame.setJMenuBar(menuBar);
frame.setContentPane(getJLabel());
// f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setTitle(filename);
frame.setResizable(false);
frame.pack();
frame.setVisible(true);
}
// draw
frame.repaint();
}
/**
* Returns the height of the picture (in pixels).
*/
public int height() {
return height;
}
/**
* Returns the width of the picture (in pixels).
*/
public int width() {
return width;
}
/**
* Returns the color of pixel (<em>x</em>, <em>y</em>).
*/
public Color get(int x, int y) {
if (x < 0 || x >= width()) throw new IndexOutOfBoundsException("x must be between 0 and " + (width()-1));
if (y < 0 || y >= height()) throw new IndexOutOfBoundsException("y must be between 0 and " + (height()-1));
if (isOriginUpperLeft) return new Color(image.getRGB(x, y));
else return new Color(image.getRGB(x, height - y - 1));
}
/**
* Sets the color of pixel (<em>x</em>, <em>y</em>) to given color.
*/
public void set(int x, int y, Color color) {
if (x < 0 || x >= width()) throw new IndexOutOfBoundsException("x must be between 0 and " + (width()-1));
if (y < 0 || y >= height()) throw new IndexOutOfBoundsException("y must be between 0 and " + (height()-1));
if (color == null) throw new NullPointerException("can't set Color to null");
if (isOriginUpperLeft) image.setRGB(x, y, color.getRGB());
else image.setRGB(x, height - y - 1, color.getRGB());
}
/**
* Is this Picture equal to obj?
*/
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null) return false;
if (obj.getClass() != this.getClass()) return false;
Picture that = (Picture) obj;
if (this.width() != that.width()) return false;
if (this.height() != that.height()) return false;
for (int x = 0; x < width(); x++)
for (int y = 0; y < height(); y++)
if (!this.get(x, y).equals(that.get(x, y))) return false;
return true;
}
/**
* Saves the picture to a file in a standard image format.
* The filetype must be .png or .jpg.
*/
public void save(String name) {
save(new File(name));
}
/**
* Saves the picture to a file in a standard image format.
*/
public void save(File file) {
this.filename = file.getName();
if (frame != null) { frame.setTitle(filename); }
String suffix = filename.substring(filename.lastIndexOf('.') + 1);
suffix = suffix.toLowerCase();
if (suffix.equals("jpg") || suffix.equals("png")) {
try { ImageIO.write(image, suffix, file); }
catch (IOException e) { e.printStackTrace(); }
}
else {
System.out.println("Error: filename must end in .jpg or .png");
}
}
/**
* Opens a save dialog box when the user selects "Save As" from the menu.
*/
public void actionPerformed(ActionEvent e) {
FileDialog chooser = new FileDialog(frame,
"Use a .png or .jpg extension", FileDialog.SAVE);
chooser.setVisible(true);
if (chooser.getFile() != null) {
save(chooser.getDirectory() + File.separator + chooser.getFile());
}
}
In: Computer Science
In: Computer Science