Test Accounts

There are 3 test accounts.

Username: Test
Password: test123

Username: Test 2
Password: testuser2

Username: Test 3
Password: testuser3

Syntax Highlighter

Moderator: Jessica

Syntax Highlighter

Postby Jessica » January 21st, 2013, 8:50 pm

python code
count = 0
while (count < 11):
print 'Count:', count
count = count + 1

print "See ya!"


1 COMMENT
March 19th, 2014, 8:15 am
Hello.. This is a comment.

Test
User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133

Re: Syntax Highlighter

Postby Jessica » January 29th, 2013, 9:28 pm

vbnet code
'Class describing the application
Public Class exploreForm

Private Sub calculateAverage(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles goBtn.Click
Dim total As Integer
Dim count As Integer
Dim calculatedAverage As Double

If IsNumeric(firstInputTB.Text) And IsNumeric(secondInputTB.Text) Then
total = CInt(firstInputTB.Text)
count = CInt(secondInputTB.Text)
If (count > 0) Then
calculatedAverage = total / count
output.AppendText(CStr(calculatedAverage) & vbCrLf)
Else
MessageBox.Show("Second value must be greater than 0")
End If
Else
output.AppendText("Enter numeric values only")

End If
End Sub
End Class


1 COMMENT
August 24th, 2013, 2:31 pm
Nice mod o_O

Test
User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133

Re: Syntax Highlighter

Postby Jessica » February 4th, 2013, 1:23 am

vbnet code
' This program will calculate an average given a total and a number of entries that
' were used to create total.
'
' uses:
' lblTotal - Label - prompt for where user should enter total
' lblCount - Label - prompt for where user should enter number of entries that made total
' totalTB - TextBox - used to get user input for total
' countTB - TextBox - used to get user input for number of entries that made total
' goBtn - Button - used by user to start task of calulating average
' outputTB - TextBox - ReadOnly(True),Multiline(True),VerticalScroll - used to show user
' result of calculation

Option Strict On
Option Explicit On
Option Infer Off
Option Compare Binary

' this is functionality of mainform
Public Class calcAveForm
' calculateAverage will get the user input and use it to calculate an average
' (not sure what sender and e are used for ... other than being necessary for
' using this method when the click event for goBtn occurs)
' This will be called when the goBtn.Click event happens.
Private Sub calculateAverage(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles goBtn.Click
Dim total As Integer ' total will hold value user enters as integer (assuming total is a whole number)
total = CInt(totalTB.Text) ' totalTB.Text is a String so I convert it to an integer before assigning it

Dim count As Integer ' this is same as total (only I'm getting the number of entries here)
count = CInt(countTB.Text)

' do the calculation and rember the result
Dim result As Double ' result will hold what is calculated .. it is a double becuase the division may have a fractional result
result = total / count

' output message to user so they can see the result
outputTB.AppendText("The average is " & CStr(result) & "." & vbCrLf)
End Sub

End Class
' Problems:
' If user does not enter any data and presses button
' program halts with an 'Invalid Cast Exception' I didn't see in my notes or text
' how to fix this .. Did I miss something?
' Also broken when user enters a count of 0. It says the answer is infinity.
' How do we fix this? Will it be discussed in class or is it in text?
' Can we make the answer less digits ... instead of 1.666666667 could it give 1.67?


User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133

Re: Syntax Highlighter

Postby Jessica » April 4th, 2013, 5:09 pm

vbnet code
Public Class Tester
Private Sub test(ByVal s As System.Object, ByVal e As System.EventArgs) Handles Main.Load
Dim array() As Integer = {10, 15, 20, 25, 30, 35, 40, 45, 50, 55}
Dim result As Integer = 0
Dim j As Integer = 2
Do While j < 10
result += array(j)
j += 1
Loop
End Sub
End Class


result: 300


vbnet code
Public Class Tester
Private Sub test(ByVal s As System.Object, ByVal e As System.EventArgs) Handles Main.Load
Dim result As Integer = 0
Dim array() As Integer = {1, -2, -3, 4, -5, 6, 7, 8, -9, 10, -11}
For i As Integer = 0 To array.Count - 1
If array(i) > 0 Then
result += array(i)
End If
Next
End Sub
End Class


result: 36


4 COMMENTS
August 24th, 2013, 2:32 pm
4

Test
August 24th, 2013, 2:32 pm
3

Test
August 24th, 2013, 2:32 pm
2

Test
August 24th, 2013, 2:31 pm
nice

Test
User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133

Re: Syntax Highlighter

Postby Jessica » September 5th, 2013, 1:48 am

python code
print("Hello, World!")


User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133

Re: Syntax Highlighter

Postby Jessica » September 25th, 2013, 10:48 am

java code
package edu.pitt.ChenHomework4;
import java.util.Scanner;
public class BankAccount {

public static void main(String[] args) {
boolean accountStatusActive = true;
double accountBalance = 1000.00;

Scanner in = new Scanner(System.in);
System.out.print("Please enter the amount that you would like to withdraw. " + "Enter -1 to exit the program: ");
double withdrawalAmount = in.nextDouble();

while (withdrawalAmount != -1) {
if (accountStatusActive) {
accountStatusActive = false;
if (accountBalance >= withdrawalAmount) {
accountBalance -= withdrawalAmount;
System.out.println(accountBalance);
} else {
System.out.println("Account balance is insufficient.");
}
}
withdrawalAmount = in.nextDouble();
accountStatusActive = true;
}
System.exit(-1); // exit program by pressing -1
}
}



Test likes this post.
User avatar
Jessica
Founder
 
Topic author
Posts: 97
Topics: 39
Blog entries: 5
Joined: October 27th, 2011, 4:30 pm
Likes: 7 posts
Liked in: 24 posts
Images: 133


Return to Testing Area

Who is online

Users browsing this forum: No registered users and 3 guests

x

#{title}

#{text}