Questions
Write a program in java which randomly generates two integer number n1 and n2 (suppose the...

Write a program in java which randomly generates two integer number n1 and n2 (suppose the range for each integer is [1, 100]), then asks the user what is the value of n1*n2, if the user’s answer is correct, call method printGoodComment to print out something nice, otherwise, call printBadComment to print out something “mean”.

The method signatures are:

                  public static void printGoodComment()

and

                  public static void printBadComment()

in your printGoodComment method, it will randomly print one sentence from the following lists:

                              good job

                              excellent

                              terrific

                              nice work

in your printBadComment method, it will randomly print one sentence from the following lists:

                              sorry, try next time

                              oops, you need more work

                              hmm, it is not correct

Hint: use Math.random and a switch statement in the printGoodComment and printBadComment methods.

  • In the printGoodComment method, use Math.random( ) to generate a random int in the rage of [0, 3] and use a switch statement to select one of the four good moments based on the value of the random int.
  • In the printBadComment method, use Math.random( ) to generate a random int in the rage of [0, 2] and use a switch statement to select one of the three bad moments based on the value of the random int.

In: Computer Science

Write a program in java which randomly generates two integer number n1 and n2 (suppose the...

Write a program in java which randomly generates two integer number n1 and n2 (suppose the range for each integer is [1, 100]), then asks the user what is the value of n1*n2, if the user’s answer is correct, call method printGoodComment to print out something nice, otherwise, call printBadComment to print out something “mean”.

The method signatures are:

                  public static void printGoodComment()

and

                  public static void printBadComment()

in your printGoodComment method, it will randomly print one sentence from the following lists:

                              good job

                              excellent

                              terrific

                              nice work

in your printBadComment method, it will randomly print one sentence from the following lists:

                              sorry, try next time

                              oops, you need more work

                              hmm, it is not correct

Hint: use Math.random and a switch statement in the printGoodComment and printBadComment methods.

  • In the printGoodComment method, use Math.random( ) to generate a random int in the rage of [0, 3] and use a switch statement to select one of the four good moments based on the value of the random int.
  • In the printBadComment method, use Math.random( ) to generate a random int in the rage of [0, 2] and use a switch statement to select one of the three bad moments based on the value of the random int.

In: Computer Science

Instructions The included program found in main.cpp is designed to find the area of a rectangle,...

Instructions

The included program found in main.cpp is designed to find the area of a rectangle, the area of a circle, or the volume of a cylinder.

However:

  • the statements are in the incorrect order;
  • the function calls are incorrect;
  • the logical expression in the while loop is incorrect;
  • the function definitions are incorrect;
  • You may assume that the value of π = 3.14159.

Rewrite the program so that it works correctly. Your program must be properly indented. (Note that the program is menu driven and allows the user to run the program as long as the user wishes.)

Format your output with setprecision(2) to ensure the proper number of decimals for testing!

I have tried previous answers on site, but they are all incorrect and fail in the Mindtap cite used for the class.

In: Computer Science

How Non-monotonic reasoning deals with incomplete and uncertain model? subject: Artificial Intelligence  

How Non-monotonic reasoning deals with incomplete and uncertain model?

subject: Artificial Intelligence  

In: Computer Science

In Java Write a method called findMax that accepts three floating-point number as parameters and returns...

In Java Write a method called findMax that accepts three floating-point number as parameters and returns the largest one.(hints: use conditional statement in the method)

In: Computer Science

Implement Radix Sort using PYTHON programming language. Use one of the two options for the algorithm...

Implement Radix Sort using PYTHON programming language. Use one of the two options for the algorithm to sort

the digits: Use Counting Sort or Bucket Sort.

• Assume the numbers are maximum 4-digit numbers.

• If using Counting Sort, you can see that your digit range is between 0 and 9 ([0…9]).

• If using Bucket Sort, you will have ten buckets labeled from 0 to 9.

Please add comments and explain every step carefully.

In: Computer Science

In C++, Convert the math expression (2+3)+4*(6-5) to post fix form and evaluate the post fix...

In C++, Convert the math expression (2+3)+4*(6-5) to post fix form and evaluate the post fix expression “3 2 * 3 – 2 /” to a value.

In: Computer Science

C++ You are going to implement your own vector class. Actually, we are using the following...

C++ You are going to implement your own vector class. Actually, we are using the following small and simplified subset of the interface from std::vector to keep things manageable:

template class DiyVector{
    public:
        DiyVector();
        ~DiyVector();

        T& at(unsigned int index) const;
        // item at index
        // throws OutOfRange

        unsigned int size() const;
        // number of items in the vector

        void pushBack(const T& item);
        // append item at the end of vector

        void popBack();
        // remove item at the end of vector
        // throws OutOfRange

        void erase(unsigned int index);
        // remove element at index
        // throws OutOfRange

        void insert(unsigned int index, const T& item);
        // insert item before element at index, with:
        // 0 <= index <= size()
        // throws OutOfRange

        class OutOfRange{};

    private:

        // your implementation goes here!
};
Your DiyVector will store items of type T in an array that is dynamically allocated on the heap, using new[].

We only expand this array, but never shrink it:

when adding an item (using pushBack or insert), if there is no currently unused element in the array, create a new array, able to hold one more element, and copy over the old items. Of course, you delete[] the old, too-short array afterwards.

when deleting an item (using popBack or erase), you simply "pack" the array by copying all items behind the erased one to close the gap (and adjust the bookkeeping of used elements). Later, when a new item is to be added (using pushBack or insert), you re-use an old space at the end of the array, instead of creating a whole new array.

Your program must not use any item storage but arrays that are created by new[]. (No statically created arrays, no vectors, no other container classes from std::)

You deliver your DiyVector as a header file called diyvector.h.

It will be automatically tested by the following program( create a seperate file named vector-tester.cpp using code below) :

#include

#include "diyvector.h"

class TestFailed{

public:

TestFailed(int seq){

sequenceNumber = seq;

}

int sequenceNumber;

};

int testNumber = 0;

#define check(CALL) { testNumber++; if ( !(CALL) ) throw TestFailed(testNumber); }

#define checkException(CALL){ \

testNumber++; \

bool exceptionRaised = false; \

try{ \

CALL; \

}catch(DiyVector::OutOfRange& o){ \

exceptionRaised = true; \

} \

if ( !exceptionRaised ) throw TestFailed(testNumber); \

}

int main(){

try{

DiyVector v;

check(v.size() == 0); // test 1

checkException(v.at(0));

v.pushBack(42);

check(v.size() == 1);

check(v.at(0) == 42);

checkException(v.at(1)); // test 5

v.pushBack(43);

check(v.size() == 2);

check(v.at(1) == 43);

check(v.at(0) == 42);

v.popBack();

v.popBack();

check(v.size()==0);

checkException(v.popBack()); // test 10

v.pushBack(142);

v.pushBack(143);

v.pushBack(144);

check(v.size()==3);

check(v.at(0)==142);

check(v.at(1)==143);

check(v.at(2)==144);

checkException(v.at(3)); // test 15

v.at(0) = 17;

check(v.at(0)==17);

checkException(v.erase(3));

checkException(v.erase(42));

v.erase(1);

check(v.size()==2);

check(v.at(0)==17); // test 20

check(v.at(1)==144);

v.pushBack('A');

v.pushBack('B');

check(v.size()==4);

check(v.at(2)==65);

check(v.at(3)==66);

v.insert(2, 22);

check(v.at(0)==17); // test 25

check(v.at(1)==144);

check(v.at(2)==22);

check(v.at(3)==65);

check(v.at(4)==66);

check(v.size()==5); // test 30

DiyVector v2;

v2.insert(0,42);

v2.pushBack(11);

v2.insert(0,44);

check(v2.size()==3);

check(v2.at(0)==44);

check(v2.at(1)==42);

check(v2.at(2)==11);

v2.popBack();

v2.insert(0,99);

check(v2.size()==3); // test 35

check(v2.at(0)==99);

check(v2.at(1)==44);

check(v2.at(2)==42);

DiyVector v3;

v3.pushBack(1);

v3.erase(0);

checkException(v3.at(0));

check(v3.size()==0); // test 40

checkException(v3.insert(1,-5));

check(v3.size()==0); // test 42

std::cout << "All tests passed!\n";

}

catch(TestFailed& tf){

std::cerr << "Test number " << tf.sequenceNumber << " failed.\n";

return 1;

}

catch(...){

std::cerr << "an unexpected exception occured\n";

std::cerr << "Tests passed so far: " << testNumber << std::endl;

return 2;

}

return 0;

}

In: Computer Science

Describe what a database is. Explain components of a database management system - (DBMS). Setup a...

Describe what a database is. Explain components of a database management system -

(DBMS). Setup a database to manage a hypothetical business. Create between 5 – 7 categories/ groups of functional areas for your business. For e.g., Personnel, Suppliers, Products, Fleet, Customers Add 20 entries. You may build this database in MS Excel, or MS Access.


please with no plagrism

In: Computer Science

in Java Write a method called randomNumber that returns a random floating-point number in the range...

in Java Write a method called randomNumber that returns a random floating-point number in the range of [-20.0, 50.0). (hints: use Random class in the method)

In: Computer Science

Examine the role of IT governance and why it is important in the IT industry. Analyze...

Examine the role of IT governance and why it is important in the IT industry.

Analyze key aspects of IT governance, including enterprise resource planning and transaction processing systems.

In: Computer Science

in c++: The area of an arbitrary triangle can be computed using the formula where a,...

in c++:

The area of an arbitrary triangle can be computed using the formula
where a, b, and c are the lengths of the sides, and s is the semiperimeter :
s = (a + b + c) / 2
1. (5 points) Write a void function that uses five parameters :
three value parameters that provide the lengths of the edges and
two reference parameters that compute the area and perimeter(not the semiperimeter).
Make your function robust.Note that not all combinations of a, b, and c produce a triangle.
Your function should produce the correct results for legal data and reasonable results for illegal combinations.

In: Computer Science

Round Robin Simulation Description: Write a program in c++ that utilizes STL queue (or your own...

Round Robin Simulation

Description: 
Write a program  in c++ that utilizes STL queue (or your own queue implementation) that simulates the round robin process scheduling algorithm. 
WITH COMMENTS
Requirement: 
- write a class Process that holds following integer information: id, arrival_time, time_needed, finished_time.
- read and initiate 5 Process objects from associated file (robin. txt)
- file format: id, arrival_time, time_needed
- once a process is finished, mark its finished_time accordingly. 
- CPU time frame: 4. 
- utilize a queue for process scheduling.
- store finished processes into a vector (first finished, first stored)
- output: print information about finished processes from the vector, in the finished order.

robin.txt:

1 0 10
2 1 12
3 5 6
4 6 10
5 7 4

In: Computer Science

You’ve been asked to install a new service called explodingwidgets. After installing the explodingwidgets package, what...

You’ve been asked to install a new service called explodingwidgets. After installing the explodingwidgets package, what is the most likely way you would start the service?


Linux/ Unix Server

In: Computer Science

I've created a C# Windows form application in Visual stuidos it allows the user to enter...

I've created a C# Windows form application in Visual stuidos it allows the user to enter information, save that information to a database, then show that information in a datagridview. Everything works fine but the datgridview. It shows that rows have been added but not the text. I can see in my database the reports that have been added so I know its alteast saving the information. I don't know what I'm doing wrong. Please help!

My code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Globalization;

namespace Reports
{
public partial class ReportsForm : Form
{
public ReportsForm()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=Blu;Initial Catalog=Reports;Integrated Security=True");
SqlCommand cmd;
private void Submitbtn_Click(object sender, EventArgs e)
{
  


  

String query = ("INSERT INTO Reports_tbl (EntryDate, ReportText) VALUES ('" + DateTime.Now + "','" + ReportsrichTextBox.Text + "')");
con.Open();
cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();

MessageBox.Show("Report Successfully Added");

ReportsrichTextBox.Text = "";

  
}

private void Form1_Load(object sender, EventArgs e)
{

SqlConnection con = new SqlConnection("Data Source=Blu;Initial Catalog=Reports;Integrated Security=True");

con.Open();

SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Reports_tbl", con);


DataSet ds = new DataSet();

da.Fill(ds,"Reports_tbl");

  
ReportsdataGridView.DataSource = ds.Tables["Reports_tbl"].DefaultView;

  

con.Close();

}
}
}

In: Computer Science