Question about Compilers & Programming Tools

1 Answer

Boolean Logic A panel has 3 switches on the front which toogle options. the state of all these buttons(on or off) must bestored in a single integer variable(not an array). How this information gets to the computer is irrelevant. Using C# or Java, write briefly the function ofsetting each button state in the variable andreading off any particular button state from the variable. Create unique global constants for each button, simply write them and the functions down and not the entire program

Posted by on

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Governor:

    An expert whose answer gotĀ voted for 20 times.

    Scholar:

    An expert who has written 20 answers of more than 400 characters.

  • Expert
  • 84 Answers

I don't know the syntax but you could easily do this with setting the switches to a constant, then adding them up. The number set would need to be something so that there would only be one solution...the one that you were looking for.

sw1 = 1
sw2 = 2
sw3 = 4

If sw1 and sw2 is both on, but sw3 is off, the number would be 3
If sw2 and sw4 was on, the number would be 6
If all were on, the number would be 7, etc.

Posted on May 09, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Wirte a pogram in java using for loop,that will print out the first 1 numbers of a fibonacii series that is:1 1 2 3 5 13 21 34 55


package com.gpt;

import javax.swing.JOptionPane;

/*
This program computes Fibonacci numbers using a recursive
method.
*/
public class Fibonacci
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter n: ");
int n = Integer.parseInt(input);

for (int i = 1; i {
int f = fib(i);
System.out.println("fib(" + i + ") = " + f);
}
System.exit(0);

}

/**
Computes a Fibonacci number.
@param n an integer
@return the nth Fibonacci number
*/
public static int fib(int n)
{
if (n return 1;
else
return fib(n - 1) + fib(n - 2);
}
}

Feb 24, 2011 | Sun Java Programming Language (cdj-275)

1 Answer

How to form an array in visual basics(Express)


samples of arrays in vb.net
1)
dim array(3) as integer

array(0)=1
array(1)=2
array(2)=3
array(3)=4

2) dim array() as integer

array=new integer(){1,2,3,4}

3) for two dimensional arrays add comma separation to the size

May 28, 2010 | Microsoft Visual Basic Enterprise Edition...

1 Answer

Saving the info that i entered in my visual basic in microsoft access.. how to code the save???


check this out
Rst.Open "users", strConnect, , , adCmdTable With Rst .AddNew .Fields("username") = txtname.Text .Fields("User_Password") = txtpws.Text .Fields("Access_Type") = cmbUserTypes.Text .Fields("Date_Created") = Now .Update End With Rst.Close

'#### connection to databas
Public connConnection As New ADODB.Connection Public rsRecordSet As New ADODB.Recordset Public rsRecordSet1 As New ADODB.Recordset Public Rst As New ADODB.Recordset Public Rst1 As New ADODB.Recordset Public Rst2 As New ADODB.Recordset Public Rst3 As New ADODB.Recordset Public strConnect As String Public ConnectionOk As Boolean


Public Sub ConnectionMOd() Dim strProvider As String Dim strDataSource As String Dim strDataBaseName As String Dim i As Integer On Error GoTo ErrorTimer strProvider = "provider=Microsoft.Jet.OLEDB.4.0;" strDataSource = App.path ' strDataBaseName = "Z:\database.mdb" ' strDataSource = App.Path strDataBaseName = "\database.mdb" strDataSource = "Data Source= " & strDataSource & strDataBaseName strConnect = strProvider & strDataSource
Set connConnection = New ADODB.Connection connConnection.CursorLocation = adUseClient connConnection.Open strConnect
Set Rst = New ADODB.Recordset Rst.CursorType = adOpenStatic Rst.CursorLocation = adUseClient Rst.LockType = adLockOptimistic ' adLockOptimistic
Set Rst1 = New ADODB.Recordset Rst1.CursorType = adOpenStatic Rst1.CursorLocation = adUseClient Rst1.LockType = adLockOptimistic
Set Rst2 = New ADODB.Recordset Rst2.CursorType = adOpenStatic Rst2.CursorLocation = adUseClient Rst2.LockType = adLockOptimistic Set Rst3 = New ADODB.Recordset Rst3.CursorType = adOpenStatic Rst3.CursorLocation = adUseClient Rst3.LockType = adLockOptimistic ConnectionOk = True Exit Sub ErrorTimer: MsgBox "Error Connecting To DataBase Please Check Network path", vbCritical, "Connection Error" End End Sub

Jan 08, 2010 | Microsoft Visual Basic Enterprise Edition...

1 Answer

HOW TO USE text.formatDouble in java


You can use these calls:

formatDouble(double inVal, int inDecs, int inLeftOfDec)
formatDouble(double inVal, int inDecs, int inLeftOfDec, boolean recursing)

inVal - double number to be formatted
inDecs - minimum significant figures
inLeftOfDec - number of fixed decimals

As far as I remember java, you use it like this:
String s;
s.formatDouble(34.5566, 2, 3);

Oct 07, 2009 | Compilers & Programming Tools

1 Answer

Sir, give me sample java problem! for i can solve.


Look at the method below which finds prime numbers. public class Primes { private static void findPrimes(int nValues, boolean printPrimes) { boolean isPrime = true; for (int i = 2; i <= nValues; i++) { isPrime = true; for (int j = 2; j < i; j++) { if (i % j == 0) { isPrime = false; break; } } if (printPrimes && isPrime) { System.out.println(i); } } } // REMAINING METHODS NOT SHOWN }Implement the method findPrimesFaster in class Primes by copying the code from the findPrimes method and modifying it to have the following features:
  • Uses labeled continue instead of break.
  • Does not require the isPrime variable.
  • Only tries to divide by integers up to the square root of the number being tested.

Sep 25, 2009 | Sun Java Programming Language (cdj-275)

1 Answer

Writing the program in c language for finding the factorial of500


If it's an int type it's already integer without exponential for examle:
void main()
{
int num=5;
num/=2;
clrscr();
printf("%d",num);
}
so the out put is 2 and no 2.5 or:

for(int i=0; i<num; i++)

so 'i' is the integer part of num.
Rate me please, thanks.

Jul 11, 2009 | Microsoft Compilers & Programming Tools

1 Answer

C++ problem


I guess this can be done quite easily with stl sort function:
http://www.sgi.com/tech/stl/sort.html
You can also code a sorting algorithm like quicksort or bubblesort yourself. This is quite fun!

Nov 28, 2008 | Compilers & Programming Tools

2 Answers

Armstrong problem


could you give me more info plz

Jun 21, 2008 | Compilers & Programming Tools

2 Answers

Help me


this the code for your problem. by the way this for vb6.0

Sub CountCharacters(Text As String)
Dim iVowel As Integer
Dim iCons As Integer
Dim iNum As Integer
Dim iSpace As Integer
Dim iOther As Integer

Dim cnt As Integer
Dim sChar As String

For cnt = 1 To Len(Text)
sChar = LCase(Mid(Text, cnt, 1))

Select Case sChar
Case "a", "e", "i", "o", "u" ' And sometimes "y"?
' Vowel
iVowel = iVowel + 1
Case "a" To "z"
' Includes the first case, but VB matches the first case and stops
iCons = iCons + 1
Case "0" To "9"
' Numbers
iNum = iNum + 1
Case " ", vbTab, vbLf
' Space characters
' Not including vbCr as this will likely be dealing with Windows text
' and I only want to match one character for a newline
iSpace = iSpace + 1
Case Else
If sChar <> vbCr Then iOther = iOther + 1
End Select
Next cnt

Debug.Print "Text: " & Text
Debug.Print "Vowels: " & CStr(iVowel)
Debug.Print "Consonants: " & CStr(iCons)
Debug.Print "Numbers: " & CStr(iNum)
Debug.Print "Space characters: " & CStr(iSpace)
Debug.Print "Other: " & CStr(iOther)
End Sub

Feb 21, 2008 | Compilers & Programming Tools

1 Answer

Help me


Sub CountCharacters(Text As String)
Dim iVowel As Integer
Dim iCons As Integer
Dim iNum As Integer
Dim iSpace As Integer
Dim iOther As Integer

Dim cnt As Integer
Dim sChar As String

For cnt = 1 To Len(Text)
sChar = LCase(Mid(Text, cnt, 1))

Select Case sChar
Case "a", "e", "i", "o", "u" ' And sometimes "y"?
' Vowel
iVowel = iVowel + 1
Case "a" To "z"
' Includes the first case, but VB matches the first case and stops
iCons = iCons + 1
Case "0" To "9"
' Numbers
iNum = iNum + 1
Case " ", vbTab, vbLf
' Space characters
' Not including vbCr as this will likely be dealing with Windows text
' and I only want to match one character for a newline
iSpace = iSpace + 1
Case Else
If sChar <> vbCr Then iOther = iOther + 1
End Select
Next cnt

Debug.Print "Text: " & Text
Debug.Print "Vowels: " & CStr(iVowel)
Debug.Print "Consonants: " & CStr(iCons)
Debug.Print "Numbers: " & CStr(iNum)
Debug.Print "Space characters: " & CStr(iSpace)
Debug.Print "Other: " & CStr(iOther)
End Sub

Feb 21, 2008 | Compilers & Programming Tools

Not finding what you are looking for?
Compilers & Programming Tools Logo

Related Topics:

75 people viewed this question

Ask a Question

Usually answered in minutes!

Top Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Fred Block
Fred Block

Level 2 Expert

289 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18304 Answers

Are you a Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...