1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pshichka [43]
2 years ago
14

Exercise : Randomizer In this exercise, we are going to create a static class Randomizer that will allow users to get random int

eger values from the method nextInt() and nextInt(int min, int max). Remember that we can get random integers using the formula int randInteger = (int)(Math.random() * (range + 1) + startingNum). nextInt() should return a random value from 1 - 10, and nextInt(int min, int max) should return a random value from min to max. For instance, if min is 3 and max is 12, then the range of numbers should be from 3 - 12, including 3 and 12.
Computers and Technology
1 answer:
Nutka1998 [239]2 years ago
4 0

Answer:

Here the code is by using java.

Explanation:

//Randomizer.java

public class Randomizer {

public static int nextInt() {

//get random number from 1-10

int randInteger = (int) (Math.random() * (11) + 1);

//if number is greater than 10 or less than 1

while (randInteger > 10 || randInteger < 1) {

randInteger = (int) (Math.random() * (11) + 1);

}

return randInteger;

}

public static int nextInt(int min, int max) {

//formula to get random number from min-max

int randInteger = (int) (Math.random() * (max + 1) + min);

while (randInteger > max || randInteger < min) {

randInteger = (int) (Math.random() * (max + 1) + min);

}

return randInteger;

}

}

//RandomizerTester.java

public class RandomizerTester {

public static void main(String[] args) {

System.out.println("Results of Randommizer.nextInt()");

for (int i = 0; i < 10; i++) {

System.out.println(Randomizer.nextInt());

}

int min = 5;

int max = 10;

System.out.println("\n Results of Randomizer.nextInt(5,10)");

for (int i = 0; i < 10; i++) {

System.out.println(Randomizer.nextInt(min, max));

}

}

}

OUTPUT:

Results of Randommizer.nextInt()

9

2

3

8

5

9

4

1

9

2

Results of Randomizer.nextInt(5,10)

9

8

9

7

5

10

5

10

7

7

You might be interested in
Cooper read an interesting article about scientists finding life on Mars and posted a link to it on his social media profile. Co
almond37 [142]
He should've paid more attention to his friends teasing him. It was an honest mistake and easy to do, we're all human. 
5 0
3 years ago
Why were QR codes created
Crank
QR codes were created to make a way for people to easily scan codes to get to a website. So you could scan (example) a movie poster to go to the website that has advertisements and tickets.
4 0
3 years ago
Read 2 more answers
Which group and tab do you need to be in to separate text into two columns? Paragraph group and Insert tab Page Layout group and
WARRIOR [948]

Answer: Page setup group and page layout tab

Explanation:

:)

7 0
3 years ago
Explain the types of network architecture with their merits and demerits
Tasya [4]

Answer:

First and foremost, what is network architecture? It's basically the physical and logical design which refers to the software, hardware, protocols and the media of transmission of data. Simply put, it refers to how computers are organized and how tasks are allocated among these computers. The two types of widely used network architectures are peer-to-peer aka P2P and client/server aka tiered.

Peer-to-Peer Architecture

In a peer-to-peer network, tasks are allocated to every device on the network. Furthermore, there is no real hierarchy in this network, all computers are considered equal and all have the same abilities to use the resources available on this network. Instead of having a central server which would act as the shared drive, each computer thats connected to this network would act as the server for the files stored on it.

8 0
2 years ago
Write a C program that will allow you to add messages to a file that has NO permissions for any user. A Unix system has many fil
amm1812

Answer:

see explaination

Explanation:

#include <iostream>

#include <fstream>

#include <sys/types.h>

#include <sys/stat.h>

#include <time.h>

#include <stdio.h>

#include <stdlib.h>

using namespace std;

int main(int agrc,char*argv[])

{

struct stat sb;

if(agrc != 2){

cout << "invalind command line arguments "<< endl;

return 0;

}

if (stat(argv[1], &sb) == -1) {

perror("stat");

exit(EXIT_FAILURE);

}

if((sb.st_mode & 777) != 0) {

cout<<"file has permission and its invalid"<<endl;

}

//chmod(argv[1], S_IRWXU);

int status = chmod(argv[1], 0200);

if(status){

cout<<"permission sucessfull change"<<endl;

}

ofstream myfile;

myfile.open (argv[1], ios::out | ios::app);

myfile<<argv[2]<<endl;

status = chmod(argv[1], 0000);

if(status){

cout<<"permission sucessfull change

0000"<<endl;

}

myfile.close();

cout << "thank you" << endl;

return 0;

6 0
3 years ago
Other questions:
  • Which of the following is a Microsoft solution that runs on a Microsoft Terminal Services server but appears, to end users, as i
    10·1 answer
  • What makes Group Policy such a powerful tool is its ability to enable security administrators to:_________.
    8·1 answer
  • Can someone tell me how to get all A's with no effort?
    5·1 answer
  • How can you logout your account and do not want to have this anymore
    12·2 answers
  • You can add envelopes to existing documents. <br> a. True <br> b. False
    10·1 answer
  • Whereas enterprise network convergence focuses on the consolidation of traditionally distinct voice, video, and data communicati
    14·1 answer
  • The ____ method returns an integer that represents the location of the substring within the string.
    13·1 answer
  • I think my knee....
    14·1 answer
  • Anyone trying to play fortnite ? im bored lol
    6·2 answers
  • Aii so is anyone pushing P?<br> if u are u a g
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!