# How It Works

InstaEDU makes it easy to find a great tutor and connect instantly

• ### Connect with the perfect tutor, anytime 24/7

Never get stuck on homework again. InstaEDU has awesome tutors instantly available around the clock.

• ### Work together with the best lesson tools

Our lesson space lets you use video, audio or text. Upload any assignment and work through it together.

• ### Try it free—then lock in a super low rate

Anyone can try InstaEDU for up to 2 hours for free. After that, rates start at just 40¢/minute.

 42 7

## Sam N.

Massachusetts Institute of Technology (MIT), Class of 2014

Major: Computer Engineering

See all Sam's info

## Teaching Experience

My major made me really strong in programing languages and math. I have been working as a private tutor since I started college. but I have also helped my friends understand math since I was in High School. Java , C/C++ , and most other computer languages.

## Extracurricular Interests

I was born in Michigan. I speak both English and Arabic Fluently.

## Top Subjects

### Algebra

It's very easy for me so I can help

### Arabic

It's my language and I used to be a language partner so I know how to  help

### Basic Math

math is my strength and what I love

### Calculus

I can easily help with anything when it comes to calculus.

I can help with the math part

### Computer Science

I'm very strong in programing languages such as Java, C, C++ and C#. I will be happy to help.

### Electrical Engineering

I'm good at it because I took so many classes.

### Geometry

Math has been the subject I loved since I started learning it. and I'm really good at it.

I enjoy helping people with all math subjects.

### Linear Algebra

I'm good at it because I've used it in so many classes and I have helped students before

### Pre-Algebra

I have helped many students.

I love math

### SAT II Mathematics Level 1

I have helped many students before

### Trigonometry

I have taken the class  and I have used it with most of my engineering classes.

 Ruby Programming This is a review for a written lesson. Ruby Programming This is a review for a written lesson. Ruby Programming This is a review for a written lesson. Java Programming Java Programming "Great help! Give him whatever questions you have and no matter how long it takes, he'll figure it out." Java Programming "Very patient. He quickly analyzed the problem and came up with more than one solution. " C++ Programming This is a review for a written lesson. Java Programming Java Programming "j" Ruby Programming "Great Guy Fast and Answered all my questions in Ruby"
1-10 of 49 Reviews

### Subject:Ruby Programming

I need a tutor to do the second problems of this a5 assignment.

### Sam responded:

Part 4:
A)
This is the regular expression that you will need to match this.
/^\d\.+\d$/ Check if the line matches this and then you can just return it. B) This regular expression will math any sentence: [A-z]{1}\s?[a-z]*\s?\!?\?? again make a method then check if the given string matches this regular expression and return it if it does. c) For this part it's asking you to define a method that will match a file path for unix. To do this you will need to use some regular expressoin and check if it's equal (~=) some path that you are matching to. Here is the regExpression that you have to use: \A(?:[0-9a-zA-Z_-]+\/?)+\z. The parenthesis indicate the numbers of$. which you could easily chose as your choice. you will have an if statment that will check if it's matching and if it's not then you set that string equal to "" ( empty String).

D) a5/re.1
To match this with a method:
def calc_re str
if str ~= /(a5/re.1)$/ then //Found. end end ### Feedback: ### Subject:Ruby Programming ### Someone asked: I need a tutor to do the fourth problem (re.rb) of this a5 assignment. ### Sam responded: Part 4: A) This is the regular expression that you will need to match this. /^\d\.+\d$/
Check if the line matches this and then you can just return it.

B)

This regular expression will math any sentence:
[A-z]{1}\s?[a-z]*\s?\!?\??

again make a method then check if the given string matches this regular expression and return it if it does.

c) For this part it's asking you to define a method that will match a file path for unix. To do this you will need to use some regular expressoin and check if it's equal (~=) some path that you are matching to. Here is the regExpression that you have to use: \A(?:[0-9a-zA-Z_-]+\/?)+\z. The parenthesis indicate the numbers of $. which you could easily chose as your choice. you will have an if statment that will check if it's matching and if it's not then you set that string equal to "" ( empty String). D) a5/re.1 To match this with a method: def calc_re str if str ~= /(a5/re.1)$/ then
//Found.
end
end

### Subject:Java Programming

working on a program that acts as a change dispenser but the program seems faulty and i can't figure out why

### Sam responded:

hi,
It's better if you put down more details describing what you need help with. but, I've done the code in my computer and it works. Please message me if you have any questions but this should be working.

// CashDispenser.java
// Represents the cash dispenser of the ATM

public class CashDispenser
{
// the default initial number of bills in the cash dispenser
private final static int INITIAL_COUNT = 500;
private int count; // number of $20 bills remaining // no-argument CashDispenser constructor initializes count to default public CashDispenser() { count = INITIAL_COUNT; // set count attribute to default } // end CashDispenser constructor // simulates dispensing of specified amount of cash public void dispenseCash( int amount ) { int billsRequired = amount / 20; // number of$20 bills required
count -= billsRequired; // update the count of bills
} // end method dispenseCash

// indicates whether cash dispenser can dispense desired amount
public boolean isSufficientCashAvailable( int amount )
{
int billsRequired = amount / 20; // number of $20 bills required if ( count >= billsRequired ) return true; // enough bills available else return false; // not enough bills available } // end method isSufficientCashAvailable } // end class CashDispenser ### Subject:Ruby Programming ### Someone asked: given: info = "2014-03-23 10:43:49 -0400" How do I print out just the date format "2014-03-23" in ruby? ### Sam responded: you can do that using regular expression matching. But really the easiest way to do this is just using those easy steps. I"m going to give you two options. They both work: 1 ) puts info[0, s.length - 15] 2) puts info[0..-15] Those should work. message me if you have any questions. ### Feedback: ### Subject:Java Programming ### Someone asked: Help from before, how do I make my iterator work. (got it working) ### Sam responded: Hi, for java I'll write you an example in how to use an itirator. if this is not what you are looking or message me and I will clarify more :). but this should help a lot. I'll write this exampl and hope you can follow and do the same for your work. import java.util.*; public class IteratorDemo { public static void main(String args[]) { // Create an array list ArrayList al = new ArrayList(); // add elements to the array list al.add("C"); al.add("A"); al.add("E"); al.add("B"); al.add("D"); al.add("F"); // Use iterator to display contents of al System.out.print("Original contents of al: "); Iterator itr = al.iterator(); while(itr.hasNext()) { Object element = itr.next(); System.out.print(element + " "); } System.out.println(); // Modify objects being iterated ListIterator litr = al.listIterator(); while(litr.hasNext()) { Object element = litr.next(); litr.set(element + "+"); } System.out.print("Modified contents of al: "); itr = al.iterator(); while(itr.hasNext()) { Object element = itr.next(); System.out.print(element + " "); } System.out.println(); // Now, display the list backwards System.out.print("Modified list backwards: "); while(litr.hasPrevious()) { Object element = litr.previous(); System.out.print(element + " "); } System.out.println(); } } This would produce the following result: Original contents of al: C A E B D F Modified contents of al: C+ A+ E+ B+ D+ F+ Modified list backwards: F+ D+ B+ E+ A+ C+ ### Subject:Java Programming ### Someone asked: Note: We are given the following binary search tree class code( attached file) and we are supposed to modify it by implementing lazy deletion (the code will also be copied and pasted here). The formal HW question is listed in the bottom. Code 1: attached Code 2: /** * internal method to remove from a subtree. * @param x the item to remove. * @param t the node that roots the subtree. * @return the new root of the subtree. */ private BinaryNode<AnyType> remove( AnyType x, BinaryNode<AnyType> t ) { if (t == null ) return t; // Item not found; do nothing int compareResult = x.compareTo( t.element ); if (compareResult < 0 ) t.left = remove( x, t.left ); else if( compareResult > 0 ) t.right = remove( x, t.right ); else if( t.left != null && t.right != null ) // Two children { t.element = findMin( t.right ).element; t.right = remove( t.element, t.right ); } else t = ( t.left != null ) ? t.left : t.right; return t; } Textbook HW Question: Weiss 4.16 Data Structures in Java 3rd edition Redo the binary search tree class to implement lazy deletion. Note carefully that this affects all of the routines. Especially challenging are findMin and findMax, which must now be done recursively. ### Sam responded: public class BinarySearchTree<AnyType extends Comparable<? super AnyType>> { private static class BinaryNode<AnyType> { // Constructors BinaryNode( AnyType theElement ) { this( theElement, null, null ); } BinaryNode( AnyType theElement, BinaryNode<AnyType> lt, BinaryNode<AnyType> rt ) { element = theElement; left = lt; right = rt; } AnyType element; // The data in the node BinaryNode<AnyType> left; // Left child BinaryNode<AnyType> right; // Right child } private BinaryNode<AnyType> root; public BinarySearchTree( ) { root = null; } public void makeEmpty( ) { root = null; } public boolean isEmpty( ) { return root == null; } public boolean contains( AnyType x ) { return contains( x, root ); } public void insert( AnyType x ) { root = insert( x, root ); } public void remove( AnyType x ) { root = remove( x, root ); } public int countNodes() { return countNodes(root); } private int countNodes(BinaryNode<AnyType> t) { return (t == null) ? 0 : 1 + countNodes(t.left) + countNodes(t.right); } public int countLeafs() { return countLeafs(root); } private int countLeafs(BinaryNode<AnyType> t) { return (t == null) ? 0 : ((t.left == null && t.right == null) ? 1 : countLeafs(t.left) + countLeafs(t.right)); } public int countFullNodes() { return countFullNodes(root); } private int countFullNodes(BinaryNode<AnyType> t) { return (t == null) ? 0 : ((t.left != null && t.right != null) ? 1 + countFullNodes(t.left) + countFullNodes(t.right) : countFullNodes(t.left) + countFullNodes(t.right)); } /** * Internal method to find an item in a subtree. * @param x is item to search for. * @param t the node that roots the subtree. * @return node containing the matched item. */ private boolean contains( AnyType x, BinaryNode<AnyType> t ) { if( t == null ) return false; int compareResult = x.compareTo( t.element ); if( compareResult < 0 ) return contains( x, t.left ); else if( compareResult > 0 ) return contains( x, t.right ); else return true; // Match } /** * Internal method to find the smallest item in a subtree. * @param t the node that roots the subtree. * @return node containing the smallest item. */ private BinaryNode<AnyType> findMin( BinaryNode<AnyType> t ) { if( t == null ) return null; else if( t.left == null ) return t; return findMin( t.left ); } /** * Internal method to find the largest item in a subtree. * @param t the node that roots the subtree. * @return node containing the largest item. */ private BinaryNode<AnyType> findMax( BinaryNode<AnyType> t ) { if( t != null ) while( t.right != null ) t = t.right; return t; } /** * Internal method to insert into a subtree. * @param x the item to insert. * @param t the node that roots the subtree. * @return the new root of the subtree. */ private BinaryNode<AnyType> insert( AnyType x, BinaryNode<AnyType> t ) { if( t == null ) return new BinaryNode<AnyType>( x, null, null ); int compareResult = x.compareTo( t.element ); if( compareResult < 0 ) t.left = insert( x, t.left ); else if( compareResult > 0 ) t.right = insert( x, t.right ); else ; // Duplicate; do nothing return t; } /** * Internal method to remove from a subtree. * @param x the item to remove. * @param t the node that roots the subtree. * @return the new root of the subtree. */ private BinaryNode<AnyType> remove( AnyType x, BinaryNode<AnyType> t ) { if( t == null ) return t; // Item not found; do nothing int compareResult = x.compareTo( t.element ); if( compareResult < 0 ) t.left = remove( x, t.left ); else if( compareResult > 0 ) t.right = remove( x, t.right ); else if( t.left != null && t.right != null ) // Two children { t.element = findMin( t.right ).element; t.right = remove( t.element, t.right ); } else t = ( t.left != null ) ? t.left : t.right; return t; } /** * Print the tree contents in sorted order. */ public void printTree( ) { if( isEmpty( ) ) System.out.println( "Empty tree" ); else printTree( root ); } /** * Internal method to print a subtree in sorted order. * @param t the node that roots the subtree. */ private void printTree( BinaryNode<AnyType> t ) { if( t != null ) { printTree( t.left ); System.out.println( t.element ); printTree( t.right ); } } } ### Subject:Computer Science ### Someone asked: Who can help me edit a c++ code which it read the student.dat which include student's name id and enrollment course and then print out the student name list, course list enrollment and find student with ID of 0,3,or 1. I have did half of them. but error came out. ### Sam responded: /* To make any class in c++ or java or any language you will need to creat a constructor For the class alot with athor methods for the class. For this case I made a code that could help you understand what's going on and how to make your assighment. A constructor is the one that is responsible for creating teh objects of students. An object is something that is a collection of infomation about a student. So let's say we have some student "Jim" when making an object of that it is now refering to more information than just his name. So instead of refering to him by his name, age, and Id, we can just say object jim and this will contain all the three information about him. There is also a toString method which will print those infomation and is usually used when making an object. other methods can be added as well such as getters and setters as needed if you are making other classes. a getter can be used to get some information about an object student ( such as his name) and a setter can set his name, age, id or whatever as needed. This is the example: read through it and let me know if you have any questions. #include <iostream> #include <conio.h> using namespace std; class Student { private: char name; int idnumber; char degree; public: Student(char,int,char); void setName(char n){name = n;} int getName(){return name;} void setIdnumber(char id){idnumber = id;} int getIdnumber(){return idnumber;} void setDegree(char d){degree = d;} int getDegree(){return degree;} }; Student::Student(char n,int id,char d){ name = n; idnumber = id; degree = d; } int main(){ Student s1, s2; s1.setName(Sara); s1.setIdnumber(333); s1.setDegree(A); s2.setName(Jack); s2.setIdnumber(222); s2.setDegree(B); cout << "name: " << s1.getName() << ",IDnumber: " << s1.getIdnumber() << ",Degree: " << s1.getDegree() << endl; cout << "name: " << s2.getName() << ",IDnumber: " << s2.getIdnumber() << ",Degree: " << s2.getDegree() << endl; getch(); return 0; } ### Subject:C++ Programming ### Someone asked: Working on a 5 card poker game (specifics with UML diagram in file below). I have already started working on it and created a card class. I am currently having trouble with my Deck class and have no idea where I am going wrong. Also having trouble how to display the Hand class. Would like to work through a work space to understand my mistakes. ### Sam responded: //This will get you started. #ifndef CARDHEADER_H #define CARDHEADER_H #include <vector> enum Face{ Ace , Two , Three , Four , Five , Six , Seven , Eight , Nine, Ten , Jack , Queen , King }; enum Suit{ Diamonds , Hearts , Clubs , Spades }; class Card{ public: Card( Face, Suit ); void get_cardvalues( Face & , Suit & ); private: Face myFace; Suit mySuit; }; class Deck{ public: Deck( void ); ~Deck(); void shuffle_cards( bool swap = false ); void print_tostring(); private: std::vector<Card> deck; }; #endif cardndeck.cc ( includes card & deck implementations ) #include <algorithm> #include <iostream> #include <ctime> #include "cardheader.h" using namespace std; Card::Card( Face face, Suit suit ){ myFace = face; mySuit = suit; } void Card::get_cardvalues( Face &face, Suit &suit ){ face = myFace; suit = mySuit; } Deck::Deck(){ int counter = 0; int i; int j; for( j = int( Ace ); j <= int( King ); j++ ){ for( i = int( Diamonds ); i <= int( Spades ); i++ ){ deck.push_back( Card( Face( i ) , Suit( j ) ) ); counter++; } } } Deck::~Deck(){ deck.clear(); } void Deck::print_tostring(){ int i; static const char *faces[] = { "Diamonds" , "Hearts" , "Clubs" , "Spades" }; static const char *suits[] = { "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }; for( i = 0; i < ( int )deck.size(); i++ ){ Face f_temp; Suit s_temp; deck[ i ].get_cardvalues( f_temp , s_temp ); cout << "[" << suits[ s_temp ] << " of " << faces[ f_temp ] << "]"; cout << endl; } cout << endl; } void Deck::shuffle_cards( bool swap ){ static bool swapper; if( !swapper && swap ){ srand( unsigned( time( NULL ))); swapper = true; } random_shuffle( deck.begin() , deck.end() ); } ### Feedback: ### Subject:Computer Science (College Advanced) ### Someone asked: Consider the following Y86 code: addl %eax %eax mrmovl 0(%ecx) %ebx cmpl %ebx %eax How many pipeline stalls (or bubbles) are required when running the above code with and without forwarding? ### Sam responded: This actually depends in the pipline kind you have. Some of them are 4 stages and others are 5. I'm going to assume that you have a 5 stage pipeline: you have: IM REG EX DM REG IM REG EX DM REG stall stall stall stall IM REG ....... As you can see the firs instruction does not depend on the second instruction, but the third instruction is in fact using the first instuction. The execution stage (EX) is the one that calculates the value of the addition because it's the one that acesses the (ALU) . So there for you will not have that value untill the value is calculated then decoded in (DM) stage then Written back to the register in (REG, the last one) stage. After that is done and since it's written back at the second half of the instruction we will have 4 stalls (waits) cycles. There are ways to solve this by forwarding. meaning you can forward the value after the end of EX stage down. But the question didn't say that and usually those questions are like this. if they don't say anything you should assume that there is notthing and it's just a regular pipeline. IM REG EX DM REG IM = Fetch stage REG = read from reg stage EX = Execution stage (ALU) DM = decoding stage REG = write back stage. let me know if you are confused with any of those parts. I attached a picture of the forwarding I was talking about. you guys will cover that later. ### Subject:C++ Programming ### Someone asked: This one is the correct one to do as well as the Algebra and lab 7, I submitted those other in error if there is another one. ### Sam responded: //This is the first class: package guiExample; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class MySTTest extends JFrame { // variables used throughout class private static JLabel output_of_Wu; private static JPanel pan1,pan2; private static JButton but1; /** * Creates & displays Celsius conversion window. */ public MySTTest() { output_of_Wu = new JLabel("output"); createPanel(); addPanel(); } private void createPanel() { pan1 = new JPanel(); but1 = new JButton("WhatsUP"); but1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { add(pan2); but1ButtonActionPerformed(evt); } }); pan2 = new JPanel(); } private void addPanel() { pan1.add(but1); pan2.add(output_of_Wu); add(pan1); } private void but1ButtonActionPerformed(ActionEvent evt) { output_of_Wu.setText(MyTestControl.whatsUp()); } } //This is the second class which has e main and the method what's up: package guiExample; import javax.swing.JFrame; public class MyTestControl { public static void main(String[] args) { JFrame frame = new MySTTest(); frame.setTitle("Test Software"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } public static String whatsUp(){ return "I'm working on a Java program"; } } /* when creating a new object of the first class the constructor is being called and then we have the first panel. Then when clicking the button "what's up" we will call the perform action for the button which in turn will call the whatUp() method in the other class. As I said you didn't provide the Student class which you had so this is a full program but it needs some modifiation ( just a little bit) if you send me the student class. If you have any questions or anything you can chat with me and we can modify it. But For now this is a working program with the needed requirement. Message me if you need any help. ### Subject:Computer Science (College Advanced) ### Someone asked: I have to implement a stack class in c++, using a vector. For push() I have: void Stack<T>::push(T && x) { if(stackVector.size() >=stackVector.capacity()) { stackVector.resize(); } stackVector.push_back(x); } however we also have a function that looks like void Stack<T>::push(const T& x). What is the difference between these two functions? Also, what is the different between these functions, and how do I implement them: Stack(); Stack(const Stack <T> &); Stack(Stack<T> &&); ### Sam responded: & is An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address). && is an rvalues are defined by exclusion, by saying that every expression is either an lvalue or an rvalue. Therefore, from the above definition of lvalue, an rvalue is an expression that does not represent an object occupying some identifiable location in memory. Examples: int globalvar = 20; int& foo() { return globalvar; } int main() { foo() = 10; return 0; } Here foo returns a reference, which is an lvalue, so it can be assigned to. Actually, the ability of C++ to return lvalues from functions is important for implementing some overloaded operators. template<typename T> void foo(T&&); Here, the following apply: When foo is called on an lvalue of type A, then T resolves to A& and hence, by the reference collapsing rules above, the argument type effectively becomes A&. When foo is called on an rvalue of type A, then T resolves to A, and hence the argument type becomes A&&. ### Subject:Computer Science ### Someone asked: Rewrite the selection sort (Programming Project 7 on page 287) so that it is a template function, with the template parameter specifying the type of data in each node. Your new selection sort function will use the template version of the node. This is the project 7 from page 287: Write a function that takes a linked list of integers and rearranges the nodes so that the integers stored are sorted into the order smallest to largest, with the smallest integer in the node at the head of the list. If the original list had any integers occurring more than once, then the changed list will have the same number of each integer. For concreteness you will use lists of integers, but your function should still work if you replace the integer type with any other type for which the less-than op- eration is part of a total order semantics. Use the fol- lowing function prototype and specification: void sort_list(node*& head_ptr); // Precondition: head_ptr is a head pointer of // a linked list of items, and these items can be // compared with a less-than operator. // Postcondition: head_ptr points to the head // of a linked list with exactly the same entries // (including repetitions if any), but the entries // in this list are sorted from smallest to // largest. The original linked list is no longer // available. Your procedure will implement the following algo- rithm (which is often called selection sort): The al- gorithm removes nodes one at a time from the original list and adds the nodes to a second list until all the nodes have been moved to the second list. The second list will then be sorted. // Pseudocode for selection sort while (the first list still has some nodes) { 1. Find the node with the largest item of all the nodes in the first list. 2. Remove this node from the first list. 3. Insert this node at the head of the second list. } After all the nodes are moved to the second list, the pointer, head_ptr, can be moved to point to the head of the second list. Note that your function will move entire nodes, not just items, to the second list. Thus, the first list will get shorter and shorter until it is an empty list. Your function should not need to call the new operator since it is just moving nodes from one list to another (not creating new nodes). ### Sam responded: Node *selectionsort(Node *list) { Node *tmp=list, *tmp2, *prev, *iLst, *jLst; Node *min; if (!list) { //empty list no need sort return list; } //swapping the nodes we require previous node (remember this is SLL) prev = list; for (iLst=list; iLst && iLst->next; iLst=iLst->next) { min = iLst; for (jLst = iLst->next; jLst; jLst = jLst->next) { //get the minimum node if (jLst->info < min->info) { //mark the minimum node we had encountered so far min = jLst; } } //swap the nodes if required if (iLst != min) { tmp = min->next; //go find min’s previous node (min node can be many nodes away from base node to be swapped) for (tmp2=iLst;tmp2->next; tmp2=tmp2->next) { if (tmp2->next == min) { break; } } //check whether node to swapped is in beggining (i.e. header node) if (prev != iLst) { prev->next = min; } else { //as we do not have special header node, if the first node and some //other node, need to be swapped, then update the list (makes new min node as //logical header) list = min; } //are nodes to be swapped neibgoring nodes? if (iLst->next == min) { //nodes to be swapped are neibhoring nodes, //then swap them simply min->next = iLst; iLst->next = tmp; } else { //nodes to be swapped are not neibhor nodes, they are apart //so, consider all scenarios min->next = iLst->next; iLst->next = tmp; tmp2->next = iLst; } //after swapping we’ve changed our iterator address, so //assign correct position to contnue sorting.. iLst = min; } //readjust previous node before we move our list pointer prev = iLst; } return list; } ### Subject:Computer Science (College Intro) ### Someone asked: write a 2d java program to assign passengers to seats on an airplane for C&B Airways. assume an airplane with the following seating system. The number represents the row and the letter represents the seat position. All the planes have 9 rows of 5 seats. the program should use defined constants where appropriate. 1......A B C D E 2......A B C D E 3......A B C D E . . . . . 9......A B C D E Letters A and E are window seats and letters B and C are aisle seats. the program should read in a letter request, R for reservation, F for free and P for print display.. R command may take a seat number (i.e., 2B) or a letter code (W ffor window, I foe aisle, and N for any seat). the program should assign the seat or indicate that the seat is unavailable (" This seat is not available or there are not anymore seats of this type"). The F command will be followed be a seat number (i.e., 7C) and should change the seat from 'X' to the appropriate letter, or indicate that the seat was not taken. The P command takes no information and displays the seats as indicated above. The program should process one additional command Q, that takes no arguments and prints out the final seat configuration and exits the program. if the input is as indicated below, the output produced is displayed. R 1A R W R 1 R 2C R 1B F 2B P F 1B R 9C R N Q SEAT 1A RESERVED SEAT 1E RESERVED SEAT 1B RESERVED SEAT 2C RESERVED SORRY SEAT 1B TAKEN SORRY SEAT 2B WAS NOT RESERVED 1 X X C D X 2 A B X C D E 3 A B C D E 9 A B C D E SEAT 1B IS AVAILABLE SEAT 9C IS RESERVED SEAT 1D IS RESERVED 1 X B C X X 2 A B X D E 3 A B C D E 9 A B X D E THANK YOU FOR FLYING WITH C&B AIRWAYS! I NEED BY 8:00 AM TOMORROW ### Sam responded: //Here is the program completed. As you can see the best way to work this out is //to use the cases and a while loop that keeps asking the user to enter something //until the "run" flag changes to false: please try to understand the code :). //Best of luck import java.util.Scanner; public class Test2{ public static void main (String [] args){ // all nulls. String [][]data_base = new String[100][5]; boolean run = true; System.out.println("Hello, This is an AirPlain reservation system: "); while(run){ System.out.println("please chose an optoin"); Scanner scan = new Scanner(System.in); String input = scan.next(); input.replaceAll("\\s+",""); char[] charArray = input.toCharArray(); switch(charArray[0]){ case 'R': { if(charArray[1] == 'W' || charArray[1] == 'I' || charArray[1] == 'N'){ if(charArray[1] == 'W'){ int flag =0; // find window seat. for(int i = 0; i<data_base.length;i++){ if(data_base[i][0] == null){ data_base[i][0] = "X"; flag =1; break; } else if(data_base[i][4] == null){ data_base[i][4] = "X"; flag = 1; break; } } if(flag ==0){ System.out.println("Seat not available"); } }if(charArray[1] == 'I'){ //find iel seat: int flag = 0; for(int i = 0; i<data_base.length;i++){ if(data_base[i][1] == null){ data_base[i][1] = "X"; flag =1; break; } else if(data_base[i][2] == null){ data_base[i][2] = "X"; flag =1; break; } } if(flag ==0){ System.out.println("Seat not available"); } }if(charArray[1] == 'N'){ //find any seat: int flag = 0; for(int i =0; i<data_base.length;i++){ for(int j=0;j<data_base[0].length;j++){ if(data_base[i][j] == null){ data_base[i][j] = "X"; flag =1; break; } } } } if(flag ==0){ System.out.println("Seat not available"); } }else{ //we have a seat number exactly requested: int flag =0; char seatNumChar = charArray[1]; int seatNum = seatNumChar - 48; if(charArray[2] == 'A'){ data_base[seatNum][0] = "X"; flag =1; }else if(charArray[2] == 'B'){ data_base[seatNum][1] = "X"; flag =1; }else if(charArray[2] == 'C'){ data_base[seatNum][2] = "X"; flag =1; } else if(charArray[2] == 'D'){ data_base[seatNum][3] = "X"; flag =1; }else if(charArray[2] == 'E'){ data_base[seatNum][4] = "X"; flag =1; } if(flag ==0){ System.out.println("Seat not available"); } } break; } case 'F':{ char seatNumChar = charArray[1]; int seatNum = seatNumChar - 48; if(charArray[2] == 'A'){ if(data_base[seatNum][0] == "X"){ data_base[seatNum][0] = "A"; }else{ System.out.println("The seat was not taken"); } } else if(charArray[2] == 'B'){ if(data_base[seatNum][1] == "X"){ data_base[seatNum][1] = "A"; }else{ System.out.println("The seat was not taken"); } }else if(charArray[2] == 'C'){ if(data_base[seatNum][2] == "X"){ data_base[seatNum][0] = "C"; }else{ System.out.println("The seat was not taken"); } }else if(charArray[2] == 'D'){ if(data_base[seatNum][3] == "X"){ data_base[seatNum][0] = "D"; }else{ System.out.println("The seat was not taken"); } }else if(charArray[2] == 'E'){ if(data_base[seatNum][0] == "X"){ data_base[seatNum][0] = "E"; }else{ System.out.println("The seat was not taken"); } } break; } case 'P':{ for(int i =0;i<data_base.length;i++){ for(int j =0; j<data_base[0].length;j++){ System.out.println(i+"......." +data_base[i][j] +" "); } } break; } case 'Q':{ System.out.println("THANK YOU FOR FLYING WITH C&B AIRWAYS!"); run = false; break; } default:{ System.out.println("WRONG INPUT"); } } // close the switch: } } } ### Feedback: ### Subject:Computer Science (College Advanced) ### Someone asked: Hi. I am working on a program where I have to print out the top 10 most used characters, words and numbers from a file. I am using a map container to store each character/word/number, then putting that into a vector of pairs so it can be sorted. (Language is C++ by the way) For numbers and words, it is counting a blank space where is shouldn't. I have tried not isspace, not \0 and anything else I can think of. Any suggestions on what else to try? Thanks Sam ### Sam responded: Hi, I would think the best solution to this is to design a method called split. this method will look at ur text file. split the words that are separated by anything you need (spaces in your case) and then store them in a vector. so your output will actually have a vector of all the strings you have in the file with no spaces at all. after having that vector you can retrieve the words however you like (add then to the map for in your example). Here is how you can do the split(...... , ......) function: vector<string>& splitstring::split(char delim, int rep) { if (!flds.empty()) flds.clear(); // empty vector if necessary string work = data(); string buf = ""; int i = 0; while (i < work.length()) { if (work[i] != delim) buf += work[i]; else if (rep == 1) { flds.push_back(buf); buf = ""; } else if (buf.length() > 0) { flds.push_back(buf); buf = ""; } i++; } if (!buf.empty()) flds.push_back(buf); return flds; } //I hope this explinatiion help, but if it doesn't message me and I will be happy to explain anything or add stuff if this solution isn't good for what you're doing. best :) ### Subject:Computer Science (College Advanced) ### Someone asked: Hi, I am looking for help with PlayFair Cipher. I am given plaintext and corresponding cipher-text and I am asked to find the key/keyword. I just need guidance as to steps on recovering the text. ### Sam responded: Hi, okay so if you are doing this with java or any other program this is pretty much what you have to do: Firstly, you're game is a double array(or a 2 diminution array) which consist of characters in each element. To make a function or method that will find a given word in the parameter you will need to go to each element in the double array( which can be done by a nested for loops): example: for(int i = 0; i<=arr.length;i++){ for(int j = 0; j<arr[0].length;j++){ // content of the method } After going to each element you will need another for loop inside (where it says "content of the method") to check if for each time you go left,right,up or down with the same distance as the length of the word or "string" given and check if it's that is equal to the word given. Be also certine to check if we are at the edge we will not need to go left for example because we will not have any elements there. going left and right shouldn't be hard but going up and down might be a bit tricky. but you can solve that by just holding the same col index and adding or subtracing (depending if it's up or down) to the row index so you can go up and down. This should give you an idea of what's need to be done and how to do it. The best way to go about this problem is to have real example and work it out on paper to see if your implimantaiton works. :) best of luck ### Feedback: ### Subject:C Programming ### Someone asked: Hi, this goes to anyone who can program well in C language. It is an easy assignment I simply do not have time to do, I have several other ones I need to get done :/. I am giving full 1 hour for someone to complete this, this is C not C++. Please do NOT use any C++ libraries in fact I think this can be done without using anything besides the standard library for the C language. OK onto the assignment: I need a program that can read in 5 currencies (Dollar, Euro, Yen, Rupee, and Pound) then I need it to organize this in stacks. "construct a virtual money pile, which tracks each donation as it is placed in a pile with like currency, and then reads each pile of currency back out in reverse order." So for example I enter$500, €350, ¥940, $420,$320, €555, INR 20
The output should look like:
$320$420 €555
500 €350 ¥940 INR 20 (INR standing for rupee symbol) To read inputs I used: (Please use getchar) C = getchar(); while (c != EOF) //EOF meaning end of file, represented by Ctrl-D { if ((c >= '0') && (c <= '9')); { x = x * 10 = (c- '0'); } c = getchar(); printf('You entered" c); --- Easy enough! Please help doing this, would really appreciate it. ### Sam responded: //Because stack if FILO (first in last out) we can make a use of that. Stack s; int flag = 1; counter =0; int numDon; string money; printf("how many donations u have? \n"); scanf ("%d",&numDon); counter = numDon; while(numDon){ printf ("Enter your donation one by one: \n"); scanf("%d", &money); s.push(money); numDon--; } //To print it: int i; for(i= 0; i<counter; i++){ String toPrint = s.pop; printf("%s",toPrint); } ### Feedback: ### Subject:C++ Programming ### Someone asked: Can someone help me write these method definitions?? I've attached the Class and Main. Please help!! Thank you. Automaton(int rule) - a constructor. Through the mutator, below, we'll sanitize rule and then convert it to our internal representation. We also need to establish the seed: a single 1 in a sea of 0s (in this assignment a 1 means an asterisk, '*', and a 0 means a blank, ' '. string toStringCurrentGen() - This returns a string consisting of the current generation, thisGen, but does so by embedding it in a returnString whose length is exactly displayWidth long. If thisGen is smaller than displayWidth, it is positioned in the center of the larger returnString, with the excess padded by extremeBit characters. If thisGen is longer than displayWidth, it has to be truncated (on both ends) so that it is perfectly centered in the returned returnString, any excess trimmed off both ends, equally. Two Mutators: bool setRule(int newRule) - converts the int newRule, a number from 0-255, to an array of eight bools. For example, if the newRule is 182, then this is the binary number 1 0 1 1 0 1 1 0, which means that the resultant array will be rule[7] = true, rule[6] = false , rule[5] = true, rule[4] = true, rule[3] = false, rule[2] = true, rule[1] = true , rule[0] = false. As usual, this must sanitize the int so that only values in the legal range 0-255 are allowed. bool setDisplayWidth(int width) - this is described by the earlier description of displayWidth and MAX_DISPLAY_WIDTH. I repeat that only odd widths are allowed (for centering purposes). void propagateNewGeneration() - this is the workhorse function. It will use the three private members thisGen, extremeBit and rule[], and create the next generation from them. This method must first append two extremeBits to each side of thisGen in order to provide it with enough bits (or chars) on each end needed by rule. This adds four chars to thisGen, temporarily. We then apply rule in a loop to the new, larger, thisGen, which creates a separate (local) nextGen string. If you do this correctly, nextGen will be two characters smaller than the recently augmented thisGen (but still two larger than the original thisGen that entered the method). You must understand this statement, conceptually, before you write your first line of code, or you will be doomed. Then, you replace the old thisGen with our new nextGen. In brief, we pad thisGen with four extremeBits, then apply rule, and we have a new nextGen, two larger than we started out with. We copy that back to thisGen to complete the cycle. Finally, we have to apply rule to three consecutive extremeBits to figure out what the new extremeBit will be for the next generation (" " or "*"?) . What do I mean by "three consecutive"? We apply rule to an int representing a 3-bit pattern inside the old generation. In this case, we are doing this way out where all the bits are the same: extremeBit. So each input will be three 0s or three 1s -- an int 0 or an int 7 -- depending on the value of extremeBit. The result will enable us determine the new value of extremeBit. We must do this before we return, so extremeBit is correct for the next call to this method. void resetFirstGen() - reloads thisGen and extremeBit to represent a 1 centered in a sea of 0s. ### Sam responded: //Here you go: //Thank you #include <iostream> #include <sstream> #include <string> #include <cstdlib> #include <stdio.h> #include <math.h> using namespace std; class Automaton { private: bool rules[8]; string thisGen; string extremeBit; int displayWidth; public: static const int MAX_DISPLAY_WIDTH = 79; Automaton(int rule); string toStringCurrentGen(); bool setRule(int rule); void resetFirstGen(); bool setDisplayWidth(int width); void propagateNewGeneration(); string applyRule(string leftPos, string midPos, string rightPos); }; int main() { int rule; do { cout << "Enter Rule (0 - 255): "; cin >> rule; } while (rule < 0 || rule > 255); Automaton Auto(rule); cout << " Generation Start (0)" << endl; for (int k = 0; k < 100; k++) { cout << Auto.toStringCurrentGen() << endl; Auto.propagateNewGeneration(); } cout << " Generation End (100)" << endl; } Automaton::Automaton(int rule) { setRule(rule); resetFirstGen(); } void Automaton::resetFirstGen() { this->displayWidth = MAX_DISPLAY_WIDTH; this->extremeBit = " "; this->thisGen = "*"; } string Automaton::toStringCurrentGen() { string returnString; returnString.resize(displayWidth, extremeBit[0]); int retLength = returnString.length(); int genLength = thisGen.length(); int startPosLess = (retLength-genLength)/2; int startPosGreat = (genLength-retLength)/2; if(thisGen.length() == displayWidth) return thisGen; else if(thisGen.length() < displayWidth) { returnString.insert(startPosLess, thisGen); returnString.erase(retLength, genLength); thisGen = returnString; return thisGen; } else if(thisGen.length() > displayWidth) { returnString.assign(thisGen, startPosGreat, retLength); thisGen = returnString; return thisGen; } } bool Automaton::setRule(int rule) { int BitVal; if (rule < 0 || rule > 255) return false; for(int k = 0; k < 8; k++) { BitVal = pow(2.0, 7-k); if ((rule&BitVal) == 0) rules[7-k] = false; else if ((rule&BitVal) == 1) rules[7-k] = true; } return true; } bool Automaton::setDisplayWidth(int width) { if(width > 0 && width <= MAX_DISPLAY_WIDTH && (width&1) == true) { this->displayWidth = width; return true; } else return false; } string Automaton::applyRule(string leftPos, string midPos, string rightPos) { string ruleString = leftPos + midPos + rightPos; string retString; int RuleNumber = 0; for(int k = 0; k < 3; k++) { if(ruleString[k] == '*') RuleNumber += pow(2.0, 2-k); } if(rules[RuleNumber]) retString = "*"; else if (!rules[RuleNumber]) retString = " "; return retString; } void Automaton::propagateNewGeneration() { int BitValue; string appExtremeBit, nextGen, leftPos, midPos, rightPos; for(int k=0; k<2; k++) appExtremeBit += extremeBit; thisGen.insert(0, appExtremeBit); thisGen.append(appExtremeBit); for(int i = 1; i < thisGen.length()-1; i++) nextGen += applyRule(leftPos=thisGen[i-1], midPos=thisGen[i], rightPos=thisGen[i+1]); thisGen = nextGen; extremeBit = applyRule(extremeBit, extremeBit, extremeBit); } ### Feedback: ### Subject:Physics ### Someone asked: Two identical permanent dipoles. each consisting of charges +q and -q separated by a distance s, are aligned along the x axis, a distance r from each other, where r>>s (a) On your whiteboard draw a diagram like the one shown. Draw vectors showing all individual forces acting on each particle. Draw heavier vectors showing the net force on each dipole. How many external forces act on each dipole? ### Sam responded: Add up the forces for the point charges left dipole force consists of two attractive forces - two repulsive forces as shown here: F(r,s) = k*q^2 * [1/(r-s)^2 + 1/(r+s)^2 - 2/r^2] k = 1/(4*pi*e0) is the Coulomb's constant. you now need to expand the factor in brackets as a Taylor expansion around s = 0. we get: [1/(r-s)^2 + 1/(r+s)^2 - 2/r^2] ~= (6s^2)/r^2 + (10s^4)/r^6 + ... O(s^6) For s<< r, ignoring all except the first nonzero term in this expansion, so: F(r,s) ~= 6*k*(q^2)*(s^2)/r^4 The magnitude of the force between widely separated dipoles (either electric or magnetic) varies as 1/r^4. ### Subject:AP Computer Science A ### Someone asked: Here is the textbook with all the listings: http://www.cs.ccsu.edu/~jones/chap07.pdf http://www.cs.ccsu.edu/~jones/chap05.pdf Written lesson is not necessary, but please make sure the program is complied without error. Please separate files by exercise name. ------------------------------------ 1.Write a recursive method to compute a fibonocci series. Start at a user supplied starting point and continue 10 places. ----------------------------------- 2.Write a recursive method RevDigs that outputs its integer parameter with the digits reversed. For example RevDigs(147) outputs 741, RevDigs(4) outputs 4. You will have to use your modulus operator (%) and integer division. --------------------------------- 3.Write a program that prompts a professor to input grades for five different courses for 10 students. Prompt the professor to enter one grade at a time using the prompt "Enter grade for student #1" and "Enter grade #1". Verify that the prefessor enters only A,B,C,D, or F. Use variables for the student numbers ( 1 through 10) and grade numbers (1 through 5). Also have your program calculate the grade point average (GPA) for each student. A student receives four grade points for an A, three grade points for a B, two grade points for a C, one grade point for a D, and zero grade points for an F. Store the grades and points in parallel arrays. Search the arrays to determine the points for the grades. The class name is GradePoint. ---------------------------------- Part A Create a class for services offered by a hair styling salon. Data fields include a String to hold the service description (for example, "Cut", "Shampoo", or "Manicure"), a double to hold the price, and an integer to hold the average minutes it takes to perform the service. The class name is HairSalon. Include a constructor that requires arguments for all three data fields and three get methods that each return one of the data field's values ( getPrice() for example). Part B Write a program named SortSalon that contains an array to hold six HairSalon objects and fill it with data. Include a method to sort the array in ascending order by price of service. Call the method and display the results. Part C Add a method to the SortSalon program that sorts the HairSalon objects in descending order by time to perform the service. Call the method and display the results. Part D Add a method to the SortSalon program that sorts the HairSalon objects in alphabetical order by service description. Call the method and display the results. Part E Add a prompt to the SortSalon program giving the user three choices; sort by description, price, or time. Depending on the user's input, call one of the three sort methods and display the results. ------------------------- ### Sam responded: #1) unsigned long fib(unsigned int n) { if (n == 0 || n == 1) { return n; } else { return fib(n - 1) + fib(n - 2); } } #2) public static void main(String[] args) { //System.out.println("Reverse of no. is " + reversDigits(91)); reversDigits(98198187); } public static void reversDigits(long number) { if (number < 10) { System.out.println(number); return; } else { System.out.println(number % 10); reversDigits(number/10); } } #3) int questin =10; while (question != 10) { System.out.println("Enter The Correct Number ! "); question = sc.nextInt(); question++; } ### Feedback: ### Subject:Computer Science ### Someone asked: who can help me using unix (knoppix)?? ### Sam responded: what do you need help with exactly? just the commands for unix in general? I can help you with that. Here is a summary of all the commands you will need for unix: //----------------------------------start here-----------------------------------------------------// cat This is one of the most flexible Unix commands. We can use to create, view and concatenate files. For our first example we create a three-item English-Spanish dictionary in a file called "dict." % cat >dict red rojo green verde blue azul <control-D> % <control-D> stands for "hold the control key down, then tap 'd'". The symbol > tells the computer that what is typed is to be put into the file dict. To view a file we use cat in a different way: % cat dict red rojo green verde blue azul % If we wish to add text to an existing file we do this: % cat >>dict white blanco black negro <control-D> % Now suppose that we have another file tmp that looks like this: % cat tmp cat gato dog perro % Then we can join dict and tmp like this: % cat dict tmp >dict2 We could check the number of lines in the new file like this: % wc -l dict2 8 The command wc counts things --- the number of characters, words, and line in a file. chmod This command is used to change the permissions of a file or directory. For example to make a file essay.001 readable by everyone, we do this: % chmod a+r essay.001 To make a file, e.g., a shell script mycommand executable, we do this % chmod +x mycommand Now we can run mycommand as a command. To check the permissions of a file, use ls -l . For more information on chmod, use man chmod. cd Use cd to change directory. Use pwd to see what directory you are in. % cd english % pwd % /u/ma/jeremy/english % ls novel poems % cd novel % pwd % /u/ma/jeremy/english/novel % ls ch1 ch2 ch3 journal scrapbook % cd .. % pwd % /u/ma/jeremy/english % cd poems % cd % /u/ma/jeremy Jeremy began in his home directory, then went to his english subdirectory. He listed this directory using ls , found that it contained two entries, both of which happen to be diretories. He cd'd to the diretory novel, and found that he had gotten only as far as chapter 3 in his writing. Then he used cd .. to jump back one level. If had wanted to jump back one level, then go to poems he could have said cd ../poems. Finally he used cd with no argument to jump back to his home directory. cp Use cp to copy files or directories. % cp foo foo.2 This makes a copy of the file foo. % cp ~/poems/jabber . This copies the file jabber in the directory poems to the current directory. The symbol "." stands for the current directory. The symbol "~" stands for the home directory. date Use this command to check the date and time. % date Fri Jan 6 08:52:42 MST 1995 echo The echo command echoes its arguments. Here are some examples: % echo this this % echoEDITOR
/usr/local/bin/emacs
% echo $PRINTER b129lab1 Things like PRINTER are so-called environment variables. This one stores the name of the default printer --- the one that print jobs will go to unless you take some action to change things. The dollar sign before an environment variable is needed to get the value in the variable. Try the following to verify this: % echo PRINTER PRINTER ftp Use ftp to connect to a remote machine, then upload or download files. See also: ncftp Example 1: We'll connect to the machine fubar.net, then change director to mystuff, then download the file homework11: % ftp solitude Connected to fubar.net. 220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready. Name (solitude:carlson): jeremy 331 Password required for jeremy. Password: 230 User jeremy logged in. ftp> cd mystuff 250 CWD command successful. ftp> get homework11 ftp> quit Example 2: We'll connect to the machine fubar.net, then change director to mystuff, then upload the file collected-letters: % ftp solitude Connected to fubar.net. 220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready. Name (solitude:carlson): jeremy 331 Password required for jeremy. Password: 230 User jeremy logged in. ftp> cd mystuff 250 CWD command successful. ftp> put collected-letters ftp> quit The ftp program sends files in ascii (text) format unless you specify binary mode: ftp> binary ftp> put foo ftp> ascii ftp> get bar The file foo was transferred in binary mode, the file bar was transferred in ascii mode. grep Use this command to search for information in a file or files. For example, suppose that we have a file dict whose contents are red rojo green verde blue azul white blanco black negro Then we can look up items in our file like this; % grep red dict red rojo % grep blanco dict white blanco % grep brown dict % Notice that no output was returned by grep brown. This is because "brown" is not in our dictionary file. Grep can also be combined with other commands. For example, if one had a file of phone numbers named "ph", one entry per line, then the following command would give an alphabetical list of all persons whose name contains the string "Fred". % grep Fred ph | sort Alpha, Fred: 333-6565 Beta, Freddie: 656-0099 Frederickson, Molly: 444-0981 Gamma, Fred-George: 111-7676 Zeta, Frederick: 431-0987 The symbol "|" is called "pipe." It pipes the output of the grep command into the input of the sort command. For more information on grep, consult % man grep head Use this command to look at the head of a file. For example, % head essay.001 displays the first 10 lines of the file essay.001 To see a specific number of lines, do this: % head -n 20 essay.001 This displays the first 20 lines of the file. ls Use ls to see what files you have. Your files are kept in something called a directory. % ls foo letter2 foobar letter3 letter1 maple-assignment1 % Note that you have six files. There are some useful variants of the ls command: % ls l* letter1 letter2 letter3 % Note what happened: all the files whose name begins with "l" are listed. The asterisk (*) is the " wildcard" character. It matches any string. lpr This is the standard Unix command for printing a file. It stands for the ancient "line printer." See % man lpr for information on how it works. See print for information on our local intelligent print command. mkdir Use this command to create a directory. % mkdir essays To get "into" this directory, do % cd essays To see what files are in essays, do this: % ls There shouldn't be any files there yet, since you just made it. To create files, see cat or emacs. more More is a command used to read text files. For example, we could do this: % more poems The effect of this to let you read the file "poems ". It probably will not fit in one screen, so you need to know how to "turn pages". Here are the basic commands: q --- quit more spacebar --- read next page return key --- read next line b --- go back one page For still more information, use the command man more. mv Use this command to change the name of file and directories. % mv foo foobar The file that was named foo is now named foobar ncftp Use ncftp for anonymous ftp --- that means you don't have to have a password. % ncftp ftp.fubar.net Connected to ftp.fubar.net > get jokes.txt The file jokes.txt is downloaded from the machine ftp.fubar.net. print This is a moderately intelligent print command. % print foo % print notes.ps % print manuscript.dvi In each case print does the right thing, regardless of whether the file is a text file (like foo ), a postcript file (like notes.ps, or a dvi file (like manuscript.dvi. In these examples the file is printed on the default printer. To see what this is, do % print and read the message displayed. To print on a specific printer, do this: % print foo jwb321 % print notes.ps jwb321 % print manuscript.dvi jwb321 To change the default printer, do this: % setenv PRINTER jwb321 pwd Use this command to find out what directory you are working in. % pwd /u/ma/jeremy % cd homework % pwd /u/ma/jeremy/homework % ls assign-1 assign-2 assign-3 % cd % pwd /u/ma/jeremy % Jeremy began by working in his "home" directory. Then he cd 'd into his homework subdirectory. Cd means " change directory". He used pwd to check to make sure he was in the right place, then used ls to see if all his homework files were there. (They were). Then he cd'd back to his home directory. rm Use rm to remove files from your directory. % rm foo remove foo? y % rm letter* remove letter1? y remove letter2? y remove letter3? n % The first command removed a single file. The second command was intended to remove all files beginning with the string "letter." However, our user (Jeremy?) decided not to remove letter3. rmdir Use this command to remove a directory. For example, to remove a directory called "essays", do this: % rmdir essays A directory must be empty before it can be removed. To empty a directory, use rm. rsh Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command % rsh solitude connects you to the machine solitude. This is one of our public workstations and is fairly fast. See also: telnet setenv % echo$PRINTER
labprinter
% setenv PRINTER myprinter

#### + How do I set up my first lesson?

Just use the the form above to send a message and schedule your first lesson!