Blog

Coursehelp
November 22, 2017
Computer science No Comments

This program is in C++! Please be sure to make comments throu…

This program is in C++! Please be sure to make comments throughout the program explaining each step.Thanks!

Create a class called Fraction to store fractions Given a command and a set of fractions, execute the command using operator overloading and print the result. Input Format The first line contains a single integer T, denoting the number of test cases. (1 <= T <= 25) Each line i of the subsequent lines consists of a command c, followed by a set of fractions of the form numerator <space> denominator, separated by a space. The possible commands are Command Instruction Example output Explanation Example input Add the two fractions1 2 1 4 /2 + 1/4=3/4 3 4 1 2 Subtract the second fraction from the first fraction 3/4-1/2 =1/4 5 10 14 7 5/10 * 14/7 Multiply the two fractions Divide the first fraction1 2 3 4 by the second fraction 2 3 12 ÷ 314 = 2/3

Expert Answer


#include<iostream>

using namespace std;

class Fraction {

private:

int numerator, denomenator;

public:

Fraction(int nume = 0, int deno =0) {

//constructor initialization

numerator = nume; denomenator = deno;

}

READ MORE
Coursehelp
Computer science No Comments

You are the network administrator for a small company with a 10…

You are the network administrator for a small company with a 10 member sales group. The sales people all have laptops, but seldom bring them into the office. How will you handle this situation?

Expert Answer


As I was a network administrator for a small company with a 10 member sales group and if all the sales people have laptops but they rarely bring them to office then How I will handle the situation is given below clearly step by step:

1. Firstly I will make a note of people who will bring the laptop regulary to the office and there are 10 members, if no one brings the laptops regulary to the office then I will Buy atleast 5 computers first.

2. Now After buying the 5 computers then i will create 2 users in every computer and then i will ask the sales people to use those computers.

READ MORE
Coursehelp
Computer science No Comments

1. (3 pts) Define a struct type that represents a smartphone. The …

C programming,
please do 1,2,3

1. (3 pts) Define a struct type that represents a smartphone. The struct should store the following data: model (a character array of size 30), color (a character), and storage space (an integer). The type should be renamed from struct smartphone to Smartphone. 2. (5 pts) Write a function called set_smartphone ), which accepts, a string, a character, an integer, and a pointer to a Smartphone. The function indirectly sets (via the pointer to the Smartphone) each component in the struct to the values passed into the function. The function does not return a value. 3. (7 pts) Write a function recursively_count vowels ( which accepts a pointer to a string, and any other parameters you see fit, and recursively counts the number of vowels in the provided string. This function should return the number of vowels in the string.

Expert Answer


1.

#include <stdio.h>
#include<stdlib.h>
#include<malloc.h>

int main()
{
struct smartphone
{
char model[30];
char color;
int storage_space;
};

typedef struct smartphone Smartphone;
}

2.

READ MORE
Coursehelp
Computer science No Comments

Design a logic circuit that provides the 2’s complement of a 4 bit …

design a logic circuit that provides the 2’s complement of a 4 bit binary number.

SHOULD ONLY HAVE ONE CIRCUI

Expert Answer


READ MORE
Coursehelp
Computer science No Comments

Submit the answers to the following questions. This will be count…

Submit the answers to the following questions. This will be counted as an additional lab grade and attendance.

Look at the following array definition.

int values[10];

How many elements does the array have?

What is the subscript of the first element in the array?

What is the subscript of the last element in the array?

Assuming that an int uses four bytes of memory, how much memory does the array use?

Consider the following array definition:

int values[5] = { 4, 7, 6, 8, 2 };

What does each of the following statements display?

cout << values[4] << endl;

cout << (values[2] + values[3]) << endl;

cout << ++values[1] << endl;

Look at the following array definition.

int numbers[5] = { 1, 2, 3 };

What values is stored in numbers[2]?

What values is stored in numbers[4]?

Is an array passed to a function by value or by reference?

Why should a function that accepts an array as an argument, and processes that array, also accept an argument specifying the array’s size?

Expert Answer


1.

  • A given array contains total of 10 elements.That is,Starting from Value[0] to Value[10].
  • The subscript for the given first element of an array is 0.
  • The subscript for the given last element of an array is 9.
  • For the 10 elements,An array uses the memory of 40 bytes in total.

2. a) cout<<Values[4];

Values[4] = 2

Prints the last element in an array because first element in an array starts from Values[0] and the next element is Values[1] and so on.

READ MORE
Coursehelp
Computer science No Comments

Array storage, sorting, and handling partially filled arrays in C++…

Array storage, sorting, and handling partially filled arrays in C++

1. Create a program in C++ that reads in a series of sales dollar amounts from a file, stores the amounts in an array, processes the array, and outputs to a file and the console the number of sales amounts, the lowest amount, the highest amount, and a complete list of the amounts in order from lowest to highest. Sample output shown on the next page.

2. The maximum number of amounts in the file is 20, but it could have less. The program must keep track of the number of amounts read in from the file, and stop at the sentinel.

3. Required functions:

(1) opening the files and file failure conditions,

(2) reading the input and storing the values,

(3) sorting the array,

(4) writing and displaying the output.

4. Create an input file named “salesAmounts.txt” with the following values in the order that they appear below vertically in the file. Zero marks the end of the data set and is not one of the amounts. The file location must be the project folder.

29.95 3.55 34.70 12.34 2.67 33.89 24.99 18.45 4.99 9.95 0.00 5.

Recommendation: Use bubble sort in your solution (code provided)

Comments: The list of what the program is to do is not in a specified order.

Expert Answer


Q.1

#include <fstream>

#include <sstream>

#include<iostream>

#include <conio.h>

#include <stdio.h>

#include <cstdlib>

#include <iomanip>

using namespace std;

int main()

{

ifstream infile;

infile.open (“C:\\Users\\NeetiS\\OneDrive\\Documents\\results.txt”); //Open File

float arr[20];

int i=0;

READ MORE
Coursehelp
Computer science No Comments

Both the letter and C) 40 nt top2 stack2) Post stack2 has been set…

both the letter and C) 40 nt top2 stack2) Post stack2 has been set to empty Boolean isFull StackType stack) W Post return FALSE if there is room for another item TRUE otherwise
Number 7)
3, 4,5,7,10

Expert Answer


Number 7:

#1. top = -1

#2. new NodeType

#3. itemPtr->info = item; [setting the info part of the node to item]

#4.itemPtr->next = stack; [setting the pointer of the new node to point to stack]

READ MORE
Coursehelp
Computer science No Comments

Exercise 1. Write a program that initializes and creates an array o…

Exercise 1. Write a program that initializes and creates an array of numbers e.g., int[] arr={10, 12, 11, 9, 7} and prints out the array in the following format: Sample output: (10, 12, 11, 9,7^* Test this with two outputs where you have changed the array elements and create arrays of different lengths. Use Java please and output with { }

Expert Answer


The entire program has been explained through the use of comments.

The entire code is pasted below in text format:

public class Main{
public static void display(int[] arr)//Display function
{
int n=arr.length;//store the length of arr
System.out.print(“{ “);//open the braces “{”
for(int i=0;i<n;i++)//loop from 0 to n-1

READ MORE
Coursehelp
Computer science No Comments

The goal in this assignment is to exercise JavaFX GUI developm…

The goal in this assignment is to exercise JavaFX GUI development and to run a task in a background thread.

The GUI is as follows:

-€ AnchorPane I TextField oK Button Sum I TextField oK Button Add 1    asgn7_screenshot.png

1) create a javaFX FXML Application, and open your FXML file using the SceneBuilder. Add the components as shown above.

2) create 2 actions in your controller file as didClickSumButton and didClickAddOneButton.

3) save your controller, and using the popup menu, call Compile File.

4) go to the SceneBuilder, and bind your methods to the buttons.

5) Implement body of didClickAddOneButton

6) Implement body of didClickSumButton

6.1) In the sum button, sum numbers from 1 to 50 in a background thread

6.2) To achieve, define a Runnable Object, and in its run function, perform the sum

operation. Please kindly pay attention that we will have 1 GUI thread and 1 background thread

running.

– If we do not use a background thread, then the long-running job will block our GUI thread.

– If we use a background thread, then updating the GUI means accessing some objects in another thread which may cause synchronization issues.

– To overcome synchronization issues of GUI update from a background thread, you can use the following logic:

                     Platform.runLater(new Runnable() {
                            public void run() {
                                // Update GUI in this function
                            }
                        });

– By using the above code piece, you will not cause any synchronization issues, and different threads update the same object safely.

6.3) After completing the definition of your Runnable object (assume its name is task), then you need to start it using:

 // Run the task in a background thread
Thread backgroundThread = new Thread(task);
// Terminate the running thread if the application exits
backgroundThread.setDaemon(true);
// Start the thread
backgroundThread.start();

6.4) To prevent the user from pressing the Sum button after the summation thread started, disable sum button in the beginning of the didClickSumButton method

6.5) At the “finally” section of the try block of “run” function of Runnable Object defined in 6.2, enable the sum button.

P.S: When the sum button is clicked, the program should be running from 1 to 50 in a background thread and the button should become unclickable during this time.

Expert Answer


Souce code:

index.fxml

<?xml version=”1.0″ encoding=”UTF-8″?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight=”-Infinity” maxWidth=”-Infinity” minHeight=”-Infinity” minWidth=”-Infinity” prefHeight=”295.0″ prefWidth=”467.0″ xmlns=”http://javafx.com/javafx/8.0.111″ xmlns:fx=”http://javafx.com/fxml/1″ fx:controller=”application.Controller”>
<children>
<TextField fx:id=”txt_sum” layoutX=”106.0″ layoutY=”103.0″ />
<TextField fx:id=”txt_add” layoutX=”106.0″ layoutY=”194.0″ />
<Button fx:id=”sum_bt” layoutX=”359.0″ layoutY=”103.0″ mnemonicParsing=”false” onAction=”#didClickSumButton” text=”Sum” />
<Button fx:id=”add_bt” layoutX=”359.0″ layoutY=”194.0″ mnemonicParsing=”false” onAction=”#didClickAddOneButton” text=”Add1″ />
</children>
</AnchorPane>

Controller.java

READ MORE
Coursehelp
Computer science No Comments

Can someone help me .. application is working for sub is not exit…

Can someone help me .. application is working for sub is not exiting with invalid inputs.

falling Distance VB

Public Class FallingDistance
Dim blnOk As Boolean
Const dblGravity As Double = 9.8D
Private Sub FallingDistance_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
‘ closes the program
Close()
End Sub

Private Sub Validation(ByRef Time As Double)
‘ validate our input-numbers
If Not Double.TryParse(txtTime.Text, Time) Then
MessageBox.Show(“Please enter valid time”)
txtTime.Focus()
txtTime.BackColor = Color.Yellow
blnOk = False
Exit Sub
End If
If Time < 1 Then
MessageBox.Show(“Please enter positive value for time”)
txtTime.Focus()
txtTime.BackColor = Color.Yellow
blnOk = False
Exit Sub
End If
blnOk = True
End Sub
‘show Output
Private Sub Display(ByVal Answer As String)
lblDistanceTravelled.Text = Answer
End Sub

Private Function Calculate(Time As Double) As Double
Dim dblDisTravelled As Double
‘ Do calculation by adding numbers
dblDisTravelled = 0.5 * dblGravity * Math.Pow(Time, 2)
Return dblDisTravelled
End Function

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
‘ create my local variables
Dim dblTime As Double
Dim dblDistance As Double
txtTime.BackColor = Color.White
Try
Validation(dblTime)
If blnOk = True Then
dblDistance = Calculate(dblTime)
End If

dblDistance = Calculate(dblTime)

Display(dblDistance.ToString)

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class

Expert Answer


Public Class FallingDistance
Dim blnOk As Boolean
Const dblGravity As Double = 9.8D
Private Sub FallingDistance_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
‘ closes the program
Close()
End Sub

Private Sub Validation(ByRef Time As Double)
‘ validate our input-numbers
If Not Double.TryParse(txtTime.Text, Time) Then

READ MORE