Questions
An equilateral triangle is a triangle whose sides are equal. You are to write a class...

An equilateral triangle is a triangle whose sides are equal. You are to write a class called Triangle, using filenames triangle.h and triangle.cpp, that will allow the creation and handling of equilateral triangles, whose sides are integers in the range 1-39.

Details:

1. The single constructor for the Triangle class should have 3 parameters: an integer size (required), which is the length of a side; a border character (optional, with a default of '#'); and a fill character (optional, with a default of '*'). If the size provided is less than 1, set the size to 1. If the size provided is greater than 39, set the size to 39. The class will need to provide internal storage for any member data that must be kept track of.
2. There should be member functions GetSize, Perimeter, and Area, which will return the size of a side, the perimeter of the triangle, and the area of the triangle, respectively. The first 2 should return integer results. The Area function should return its result as a double.
3. There should be member functions Grow and Shrink, which will increase or decrease (respectively) the size of the triangle's sides by 1, unless this would cause the size to go out of bounds (out of the 1-39 range); in the latter case, Grow and Shrink should make no change to the size

4. There should be member functions SetBorder and SetFill, which each allow a new border or fill character (respectively) to be passed in as a parameter. There is a chart of ASCII characters in an appendix of the textbook. The characters that should be allowed for the border or fill characters are any characters from the '!' (ascii 33) up through the '~' (ascii 126). If an attempt is made to set the border or fill characters to anything outisde the allowable range, the function should set the border or fill back to its original default (the ones listed for the constructor -- the border default is '#' and the fill default is '*').

5. There should be a member function called Draw that will display a picture of the triangle on the screen. You may assume that the cursor is already at the beginning of a line when the function begins, and you should make sure that you leave the cursor on the line following the picture afterwards (i.e. print a newline after the last line of the triangle). Use the border character to draw the border of the triangle, and use the fill character to draw the internal characters. Separate the characters on a line in the picture by a single space to make the triangle look more proportional (to approximate the look of an equilateral triangle). You may not use formatting functions like setw to draw the triangle. This must be handled with loops. (You will only print out the newline, spaces, the border character, and maybe the fill character on any given line).

6. Provide a member function called Summary that displays all information about a triangle: its size, perimeter, area, and a picture of what it looks like. When displaying the area (decimal data), always show exactly 2 decimal places. Your output should be in the exact same format as mine (seen in the linked sample run below)

t1 has size = 1 units.
# 

t2 has size = 7 units.
      ^ 
     ^ ^
    ^ * ^
   ^ * * ^
  ^ * * * ^
 ^ * * * * ^
^ ^ ^ ^ ^ ^ ^

t3 has size = 12 units.
           X 
          X X
         X O X
        X O O X
       X O O O X
      X O O O O X
     X O O O O O X
    X O O O O O O X
   X O O O O O O O X
  X O O O O O O O O X
 X O O O O O O O O O X
X X X X X X X X X X X X

t4 has size = 39 units.
                                      $ 
                                     $ $
                                    $ o $
                                   $ o o $
                                  $ o o o $
                                 $ o o o o $
                                $ o o o o o $
                               $ o o o o o o $
                              $ o o o o o o o $
                             $ o o o o o o o o $
                            $ o o o o o o o o o $
                           $ o o o o o o o o o o $
                          $ o o o o o o o o o o o $
                         $ o o o o o o o o o o o o $
                        $ o o o o o o o o o o o o o $
                       $ o o o o o o o o o o o o o o $
                      $ o o o o o o o o o o o o o o o $
                     $ o o o o o o o o o o o o o o o o $
                    $ o o o o o o o o o o o o o o o o o $
                   $ o o o o o o o o o o o o o o o o o o $
                  $ o o o o o o o o o o o o o o o o o o o $
                 $ o o o o o o o o o o o o o o o o o o o o $
                $ o o o o o o o o o o o o o o o o o o o o o $
               $ o o o o o o o o o o o o o o o o o o o o o o $
              $ o o o o o o o o o o o o o o o o o o o o o o o $
             $ o o o o o o o o o o o o o o o o o o o o o o o o $
            $ o o o o o o o o o o o o o o o o o o o o o o o o o $
           $ o o o o o o o o o o o o o o o o o o o o o o o o o o $
          $ o o o o o o o o o o o o o o o o o o o o o o o o o o o $
         $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
        $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
       $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
      $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
     $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
    $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
   $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
  $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
 $ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

t1 now has size = 1 units.
t2 now has size = 6 units.
t3 now has size = 13 units.
t4 now has size = 39 units.
t2 has perimeter = 18 units.
t3 has perimeter = 39 units.
t2 has area = 15.5885 square units.

t3 has area = 73.1791 square units.

# 
t1 grows:
 # 
# #
... and grows:
  # 
 # #
# # #

t1 now has size = 6 units.
     ^ 
    ^ ^
   ^ * ^
  ^ * * ^
 ^ * * * ^
^ ^ ^ ^ ^ ^
t2 now looks like:
     @ 
    @ @
   @ - @
  @ - - @
 @ - - - @
@ @ @ @ @ @

t2 now looks like:
     # 
    # #
   # * #
  # * * #
 # * * * #
# # # # # #


Here is a summary on t3:
Size of triangle's side = 13 units.
Perimeter of triangle = 39 units.
Area of triangle = 73.18 units.
Triangle looks like:
            X 
           X X
          X O X
         X O O X
        X O O O X
       X O O O O X
      X O O O O O X
     X O O O O O O X
    X O O O O O O O X
   X O O O O O O O O X
  X O O O O O O O O O X
 X O O O O O O O O O O X
X X X X X X X X X X X X X

7. I am providing a sample driver program (called driver.cpp) that uses objects of type Triangle and illustrates sample usage of the member functions.

#include <iostream>
#include <iomanip>
#include "triangle.h"

using namespace std;

int main() 
{
  // create some Triangles
  Triangle t1( -5 ), t2( 7, '^' ), t3( 12, 'X', 'O' ), t4( 50 , '$' , 'o');
  // display original Triangles

  cout << "t1 has size = " << t1.GetSize() << " units.\n";
  t1.Draw();
  cout << "\nt2 has size = " << t2.GetSize() << " units.\n";
  t2.Draw();
  cout << "\nt3 has size = " << t3.GetSize() << " units.\n";
  t3.Draw();
  cout << "\nt4 has size = " << t4.GetSize() << " units.\n";
  t4.Draw();
  cout << '\n';

  t1.Shrink(); // demonstrate shrink
  t2.Shrink();
  t3.Grow(); // and grow
  t4.Grow();
  cout << "t1 now has size = " << t1.GetSize() << " units.\n";
  cout << "t2 now has size = " << t2.GetSize() << " units.\n";
  cout << "t3 now has size = " << t3.GetSize() << " units.\n";
  cout << "t4 now has size = " << t4.GetSize() << " units.\n";

  // demonstrate perimeter
  cout << "t2 has perimeter = " << t2.Perimeter() << " units.\n"; 
  cout << "t3 has perimeter = " << t3.Perimeter() << " units.\n"; 
  // and area
  cout << "t2 has area = " << t2.Area() << " square units.\n\n"; 
  cout << "t3 has area = " << t3.Area() << " square units.\n\n"; 

  t1.Draw();
  t1.Grow();               // show that fill character
  cout << "t1 grows:\n";   // appears only when size
  t1.Draw();               // is at least 3
  t1.Grow();
  cout << "... and grows:\n";
  t1.Draw();
  cout << '\n';

  t1 = t2; // demonstrate the default overload of the
  // assignment operator
  cout << "t1 now has size = " << t1.GetSize() << " units.\n";
  t1.Draw(); 

  // demonstrate the changing of border and fill characters
  t2.SetBorder('@');
  t2.SetFill('-');
  cout << "t2 now looks like:\n";
  t2.Draw();
  cout << '\n';
  t2.SetBorder('\n');    // illegal border
  t2.SetFill('\a');      // illegal fill
  cout << "t2 now looks like:\n";
  t2.Draw();
  cout << '\n';

  cout << "\nHere is a summary on t3:\n"; // demonstrate summary
  t3.Summary();

  return 0;
}

Your class declaration and definition files must work with my main program, as-is (do not change my program to make your code work!). You are encouraged to write your own driver routines to further test the functionality of your class, as well. Most questions about the required behavior of the class can be determined by carefully examining my driver program and the sample execution. Keep in mind, this is just a sample. Your class must meet the requirements listed above in the specification -- not just satisfy this driver program. (For instance, I haven't tested every illegal fill character in this driver program -- I've just shown a sample). Your class will be tested with a larger set of calls than this driver program represents.

In: Computer Science

How would Hyper-V be installed on a Windows Server Core installation?

How would Hyper-V be installed on a Windows Server Core installation?

In: Computer Science

The chapter metiones acitve-passive clustering configurations. Define what that is, and why would you use it.

The chapter metiones acitve-passive clustering configurations. Define what that is, and why would you use it.

In: Computer Science

c++120 Holideals at the Movies! We have special movie tickets on holidays! Prices are discounted when...

c++120

Holideals at the Movies!

We have special movie tickets on holidays! Prices are discounted when you buy a pair of tickets.

Create a program for the HoliDeals event that computes the subtotal for a pair of tickets. The program should ask the the ages of the first and second guests to compute the price.

There are different pricing structures based on the guests' age.

Children tickets cost $10 (age below 13)

Young Adult tickets cost $13 (age below 21)

Adult tickets cost $15 (age below 65)

Senior tickets cost $10 (age 65 and over)

To simplify the problem, let's assume that parents/guardians will always accompany pairs of children who will watch a movie.

The pricing structure should be displayed to the user. Please see the sample output below to guide the design of your program.

Welcome to HoliDeals at the Movies!
Tickets tonight can only be bought in pairs.
Here are our movie ticket deals:

Children - $10.00
Young Adults - $13.00
Adults - $15.00
Seniors - $10.00

Please enter the age of the person for the first guest: 15
Please enter the age of the person for the second guest: 16

The Subtotal for the ticket cost is: $26.00.

Q2:

Salary Calculator

Create a program that computes the salary based on an employee's hourly wage and hours worked. Use the following formulas:

Less than or equal to 40 hours worked

hourly wage * hours worked

Over 40, but less than or equal to 65 hours worked

(hourly wage * 40) + (hours worked - 40) * (hourly wage * 1.5)

Over 65 hours worked

(hourly wage * 40) + (hourly wage * 1.5) * 25 + (hours worked - 65) * hourly wage * 2

Please see the sample output below to guide the design of your program.

Hourly wage: 12
Hours worked: 20
Total Salary Owed: $240.00

In: Computer Science

Describe the components of Hyper-V and the process for installing it.

Describe the components of Hyper-V and the process for installing it.

In: Computer Science

Define predicates and prove the following using the appropriate rules of inference: All action movies are...

Define predicates and prove the following using the appropriate rules of inference:

All action movies are popular. There is an action movie filmed in Iowa. Therefore, some popular movie was filmed in Iowa.

In: Computer Science

In python, Modify your mapper to count the number of occurrences of each character (including punctuation...

In python,

Modify your mapper to count the number of occurrences of each character (including punctuation marks) in the file.

Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.

import sys
sys.path.append('.')

for line in sys.stdin:
   line = line.strip() #trim spaces from beginning and end
   keys = line.split() #split line by space
   for key in keys:
       value = 1
       print ("%s\t%d" % (key,value)) #for each word generate 'word TAB 1' line

In: Computer Science

In python, 1- Modify your mapper to count words after removing punctuation marks during mapping. Practice...

In python,

1- Modify your mapper to count words after removing punctuation marks during mapping.

Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.

import sys
sys.path.append('.')

for line in sys.stdin:
   line = line.strip() #trim spaces from beginning and end
   keys = line.split() #split line by space
   for key in keys:
       value = 1
       print ("%s\t%d" % (key,value)) #for each word generate 'word TAB 1' line

In: Computer Science

Working with strings can lead to various security flaws and errors in software development using the...

Working with strings can lead to various security flaws and errors in software development using the C++ language. What are the common string manipulation errors that can be encountered? How can these errors be resolved and/or limited? What tips can be utilized to identify security vulnerabilities related to strings in C++? Be sure to provide an appropriate source code example to illustrate your points.

In: Computer Science

Write a program that first asks the user to input 10 different integers a_1-a_10 and another...

Write a program that first asks the user to input 10 different integers a_1-a_10 and another integer b, then outputs all the pairs of the integers a_i and a_j satisfying a_i+a_j=b, i!=j. If there is no such pair, output “not found.”

In: Computer Science

Write a class to keep track of a balance in a bank account with a varying...

Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero).

The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not allow more money to be withdrawn than what is available in the account, nor should you allow for negative deposits.

Finally, there should be a function that adds interest to the balance (interest accrual) at the current interest rate. This function should have a parameter indicating how many months’ worth of interest are to be added (for example, 6 indicate the account should have 6 months’ added). Interest is accrued from an annual rate. The month is representative of 1/12 that amount. Each month should be calculated and added to the total separately.

For example:

            1 month accrued at 5% APR is Balance = ((Balance * 0.05)/12) + Balance;

            For 3 months the calculations you repeat the statement above 3 times.

Use the class as part of the interactive program provided below.

THERE ARE 3 DOCUMENTS

FILE Account.cpp:

#include "Account.h"

//constructor

Account::Account()

{

balance = 0;

rate = .05;

}

Account::Account(double startingBalance)

{

balance = startingBalance;

rate = .05;

}

double Account::getBalance()

{

return balance;

}

FILE Account.h:

#pragma once

class Account

{

private:

double balance;

double rate;

public:

Account();

Account(double);//enter balance

double getBalance();

double getRate();

};

FILE Source.cpp:

#include <iostream>
#include "Account.h"

using namespace std;
int menu();
void clearScreen();
void pauseScreen();
int main()
{
   int input = 0;
   double balance = 0.0, amount = 0.0;
   int month = 0;
   Account acct(100.00); //create instance of account
   do
   {
       input = menu();
       switch (input)
       {
           case 1: cout << acct.getBalance();
           pauseScreen();
           break;
           case 2: cout << acct.getRate();
           pauseScreen();
           break;
           case 3:
               cout << "Enter amount :";
               cin >> amount;
               if(amount < 0.0)
               {
                   cout << "Amount should be more than 0." << endl;
               }
               else
               {
                   acct.deposit(amount);
               }
           break;
           case 4:
               balance = acct.getBalance();
               cout << "Enter amount: ";
               cin >> amount;
               if(amount > balance || amount < 0.0)
               {
                   cout << "balance is less than entered amount OR you entered nagative amount." << endl;
               }
               else
               {
                   acct.withdrown(amount);
               }
           break;
           case 5:
              
               cout << "Enter month: " << endl;
               cin >> month;
               if(month < 1)
               {
                   cout << "Month should be more than 0" << endl;
               }
               acct.AccrueInterest(month);
           break;
           case 6: //ToDo
           cout << "Goodbye";
           pauseScreen();
       }
       clearScreen();
   } while (input != 6);
}
int menu()
{
   int input;
   cout << "Enter the number for th eoperation you wish to perform from the menu." << endl
   << "1. Check Balance" << endl
   << "2. Check Current Rate" << endl
   << "3. Deposit to Account" << endl
   << "4. Withdraw from Account" << endl
   << "5. Accrue Interest" << endl
   << "6. Exit program" << endl << endl;
   cout << "Enter Choice: ";
   cin >> input;
   while (input < 1 or input > 6)
   {
       cout << "Enter a valid Choice from the menu: ";
       if (std::cin.fail())
       {
           std::cin.clear();
           std::cin.ignore(1000, '\n');
       }
       cin >> input;
   }
   return input;
}
void clearScreen()
{
   system("CLS");
   if (std::cin.fail())
   {
       std::cin.clear();
       std::cin.ignore(1000, '\n');
   }
}
void pauseScreen()
{
   std::cin.clear();
   std::cin.ignore(1000, '\n');
   std::cout << "\n---Enter to Continue!---\n";
   std::cin.get();
}

In: Computer Science

The Menu-driven Program: Write a menu-driven program to implement a roomsboard for a classroom reservations system....

  1. The Menu-driven Program:

Write a menu-driven program to implement a roomsboard for a classroom reservations system. The menu includes the following options:

  1. Add new room.
    The program will prompt the user to enter the roomID, courseID and time of the new reserved room, then will call the add() method from the RoomsBoard class.
  2. Remove all occurrences of a room.
    The program will prompt the user to input the room ID to be removed, then call the remove() method from the RoomsBoard class.
  3. Remove all rooms except a room.
    The program will prompt the user to input the room ID to be kept, then call the remove_all_but () method from the RoomsBoard class.
  4. Clear the RoomsBoard.

The program will call the removeAll() method from the RoomsBoard class.

  1. Split the list of rooms into two lists by calling the method split() from the RoomsBoard class.
  2. Display RoomsBoard.
    The program will call the listRooms() method from the RoomsBoard class.
  3. Display the reservations of a room.
    The program will call the listReservations() method from the RoomsBoard class to display all reservations of this room with the given roomID.
  4. Exit.

add it to the following code:

package Chegg;
public class ReservedRoom {
    private String roomID; //data member declaration
    private String courseID;
    private int time;

    public ReservedRoom(String roomID, String courseID, int time) { // constructor

        this.roomID = roomID;
        this.courseID = courseID;
        this.time = time;
    }

    public String getRoom() { //get methods
        return roomID;
    }

    public String getCourse() {
        return courseID;
    }

    public int getTime() {
        return time;
    }

    @Override
    public String toString() { // return string representation of ReservedRoom Object
        return "ReservedRoom [roomID=" + roomID + ", courseID=" + courseID + ", time=" + time + "]";
    }

}

----------------------------------------------------------------------------------------------------------------------------------

RoomsBoard class:

package Chegg;
public class RoomsBoard {
    ReservedRoomNode head;                 //Node for storing head of the list
    private int size=0;                    //variable for storing size
    public void add(ReservedRoom r)
    {
        ReservedRoomNode node=new ReservedRoomNode(r);
        ReservedRoomNode current;               //Node to traverse the list
        if(head==null|| head.getroom().getTime()>r.getTime())
        {
            node.setNext(head);
            head=node;
            size++;
        }
        else
        {
            current=head;
            while(current.getNext()!=null&& current.getNext().getroom().getTime()<r.getTime())
            {
                current=current.getNext();
            }
            node.setNext(current.getNext());
            current.setNext(node);
            size++;
        }

    }
    public void remove(String roomId)
    {
        if(head==null) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head,temp=null;
        while(current!=null && current.getroom().getRoom()==roomId)
        {
            head=current.getNext();
            current=head;
            size--;
        }
        while(current!=null)
        {
            while(current!=null && current.getroom().getRoom()!=roomId)
            {
                temp=current;
                current=current.getNext();
            }
            if(current==null)
                return;
            temp.setNext(current.getNext());
            current=temp.getNext();
            size--;
        }
    }
    public void listRooms()
    {
        if(isEmpty()) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;                   //Node to traverse the list
        while(current!=null)
        {
            System.out.print(current);
            current=current.getNext();
        }
        System.out.println();
        System.out.println("-------------------------------------------------");
    }
    public void remove_all_but(String roomId)
    {
        if(isEmpty()) {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current.getroom().getRoom()!=roomId && current!=null)
        {
            current=current.getNext();
        }
        if(current==null)
            return;
        current.setNext(null);
        head=current;
        size=1;
    }
    public void removeAll()
    {
        head=null;                               //assigning null to head removes all nodes
        size=0;
    }
    public void split(RoomsBoard board1,RoomsBoard board2)
    {
        if(this.isEmpty())
        {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current!=null)
        {
            if(current.getroom().getTime()<=12)                    //board1 will store rooms with  timings before and at 12
                board1.add(current.getroom());
            else
                board2.add(current.getroom());                     //board2 will store rooms with timings after 12
            current=current.getNext();

        }
        System.out.print("Rooms before and at 12:");
        System.out.println();
        board1.listRooms();
        System.out.println();
        System.out.println("Rooms after 12:");
        board2.listRooms();

    }
    public void listReservations(String roomID)
    {
        if(isEmpty())
        {
            System.out.println("Number of Reserved Rooms: 0");
            return;
        }
        ReservedRoomNode current=head;
        while(current!=null)
        {
            if(current.getroom().getRoom()==roomID)
                System.out.println(current.getroom().toString());
            current=current.getNext();
        }
        System.out.println("--------------------------------------------------------");
    }
    public boolean isEmpty()
    {
        return head==null;
    }
    public int size()
    {
        return size;
    }
}

------------------------------------------------------------------------------------------------------------------------

RoomsBoardMain class

package Chegg;

public class RoomsBoardMain {
    public static void main(String[] args) {
        ReservedRoom r1=new ReservedRoom("98","maths",15);
        ReservedRoom r2=new ReservedRoom("94","physics",12);
        ReservedRoom r3=new ReservedRoom("99","english",9);
        ReservedRoom r4=new ReservedRoom("98","geography",11);
        ReservedRoom r5=new ReservedRoom("99","history",18);
        ReservedRoom r6=new ReservedRoom("101","geology",22);
        ReservedRoom r7=new ReservedRoom("98","chemistry",11);
        RoomsBoard list=new RoomsBoard();
        RoomsBoard board1=new RoomsBoard();
        RoomsBoard board2=new RoomsBoard();

        list.add(r1);
        list.add(r2);
        list.add(r3);
        list.add(r4);
        list.add(r5);
        list.add(r6);
        list.add(r7);
        list.listRooms();
        System.out.println("------------------------------------------");
        list.remove("98");
        System.out.println("Reserverd Rooms after removing room with ID=98");
        list.listRooms();
        list.split(board1,board2);
        System.out.println("Reservation for Room with ID=99");
        list.listReservations("99");
        System.out.print("Number of Reservations is Empty: ");
        System.out.println(list.isEmpty());
        System.out.println("Number of Reserved Rooms: "+list.size());
        System.out.println("----------------------------------------");
        System.out.println("Removing all Reserved Rooms except with id=101");
        list.remove_all_but("101");
        list.listRooms();
        System.out.println("------------------------------------");
        System.out.println("After Removing all reservations");
        list.removeAll();
        list.listRooms();
    }
}

-----------------------------------------------------------------------------------------------------------------------

ReservedRoomNode class

package Chegg;

public class ReservedRoomNode {                                     //class for creating nodes of ReservedRoom
     ReservedRoom room;
    ReservedRoomNode next;
    public ReservedRoomNode(ReservedRoom room)                             //constructor for creating Node
    {
        this.room=room;
    }

    public ReservedRoom getroom() {
        return room;
    }

    public void setRoom(ReservedRoom room) {
        this.room = room;
    }

    public ReservedRoomNode getNext() {
        return next;
    }

    public void setNext(ReservedRoomNode next) {
        this.next = next;
    }

    @Override
    public String toString() {
        return room.toString() ;

    }
}

In: Computer Science

C programming assignment. instructions are given below and please edit this code only. also include screenshot...

C programming assignment.

instructions are given below and please edit this code only.

also include screenshot of the output

//In this assignment, we write code to convert decimal integers into hexadecimal numbers
//We pratice using arrays in this assignment
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

//convert the decimal integer d to hexadecimal, the result is stored in hex[]
void dec_hex(int d, char hex[])
{
   char digits[] ={'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
                   'C', 'D', 'E', 'F'};

   int k = 0;
   //Fill in your code below
   //It should not be hard to obtain the last digit of a hex number
   //Then what?
   //If we are getting the digits in a reverse order, what should we do in the end?
  


   //Make sure the last character is a zero so that we can print the string correctly
   hex[k] = '\0';
}

// Do not change the code below
int main()
{
   int d;
   char hex[80];
  
   printf("Enter a positive integer : ");
   scanf("%d", &d);
   dec_hex(d, hex);
   printf("%s\n", hex);
   return 0;
}

In: Computer Science

Write a shell script that will create a new password-type file that contains user information. The...

Write a shell script that will create a new password-type file that contains user information. The file should contain information about the last five users added to the system with each line describing a single user. This information is contained in the last five lines of both the /etc/shadow and the /etc/passwd files. Specifically, you should produce a file where each line for a user contains the following fields: user name, encrypted password, and shell. The fields should be separated using the colon (:) character.

In: Computer Science

Answer these using VISUAL STUDIOS not CTT or PYTHON 1.Write an expression that evaluates to true...

Answer these using VISUAL STUDIOS not CTT or PYTHON

1.Write an expression that evaluates to true if the value of the integer variable x is divisible (with no remainder) by the integer variable y. (Assume that y is not zero.)

2.Write an expression that evaluates to true if the value of the integer variable numberOfPrizes is divisible (with no remainder) by the integer variable numberOfParticipants. (Assume that numberOfParticipants is not zero.)

3.Write an expression that evaluates to true if the integer variable x contains an even value, and false if it contains an odd value.

4.Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max.

In: Computer Science